diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/completion/common.lua | 38 | ||||
-rw-r--r-- | test/type_inference/init.lua | 11 |
2 files changed, 46 insertions, 3 deletions
diff --git a/test/completion/common.lua b/test/completion/common.lua index 787549f7..95903acb 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -2640,9 +2640,9 @@ class2:<??> TEST [[ --- @class Emit ---- @field on fun(eventName: string, cb: function) ---- @field on fun(eventName: '"died"', cb: fun(i: integer)) ---- @field on fun(eventName: '"won"', cb: fun(s: string)) +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) local emit = {} emit:on('<??>') @@ -2656,6 +2656,22 @@ TEST [[ --- @field on fun(eventName: '"won"', cb: fun(s: string)) local emit = {} +emit.on('died', <??>) +]] +{ + [1] = { + label = 'fun(i: integer)', + kind = define.CompletionItemKind.Function, + } +} + +TEST [[ +--- @class Emit +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) +local emit = {} + emit:on('won', <??>) ]] { @@ -2666,6 +2682,22 @@ emit:on('won', <??>) } TEST [[ +--- @class Emit +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) +local emit = {} + +emit.on(emit, 'won', <??>) +]] +{ + [1] = { + label = 'fun(s: string)', + kind = define.CompletionItemKind.Function, + } +} + +TEST [[ local function f() local inferCache in<??> diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index ef2d1f62..7316730e 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -941,6 +941,17 @@ emit:on("died", function (<?i?>) end) ]] +TEST 'integer' [[ +--- @class Emit +--- @field on fun(self: Emit, eventName: string, cb: function) +--- @field on fun(self: Emit, eventName: '"died"', cb: fun(i: integer)) +--- @field on fun(self: Emit, eventName: '"won"', cb: fun(s: string)) +local emit = {} + +emit.on(self, "died", function (<?i?>) +end) +]] + TEST '👍' [[ ---@class 👍 local <?x?> |