diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/crossfile/hover.lua | 39 | ||||
-rw-r--r-- | test/diagnostics/type-check.lua | 17 | ||||
-rw-r--r-- | test/hover/init.lua | 6 | ||||
-rw-r--r-- | test/type_inference/init.lua | 41 |
4 files changed, 85 insertions, 18 deletions
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 3cd560ff..7763d643 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -575,7 +575,7 @@ function f(x: string, y: table) @*param* `x` — this is comment -@*param* `y` — comment 1 +@*param* `y` — comment 1 @*return* `name` — comment 2 @@ -746,7 +746,7 @@ function f(a: boolean) --- -@*param* `a` — xxx +@*param* `a` — xxx ```lua a: @@ -1308,7 +1308,7 @@ local n: integer --- - comments]] +comments]] } TEST { @@ -1365,7 +1365,7 @@ local n: integer --- - comments]] +comments]] } TEST { @@ -1384,7 +1384,7 @@ local n: integer --- - comments]] +comments]] } TEST { @@ -1461,7 +1461,7 @@ TEST { --- - comments]] +comments]] } TEST { @@ -1708,7 +1708,7 @@ local x: unknown --- -See: [A](file:///a.lua#1#10) comment1]] +See: [A](file:///a.lua#1#10) comment1]] } TEST { {path = 'a.lua', content = [[ @@ -1728,8 +1728,8 @@ local x: unknown --- See: - * [A](file:///a.lua#1#10) comment1 - * [TTT](file:///a.lua#3#0) comment2]] + * [A](file:///a.lua#1#10) comment1 + * [TTT](file:///a.lua#3#0) comment2]] } TEST { {path = 'a.lua', content = [[ @@ -1755,3 +1755,24 @@ comment2 function f() ```]] } + +TEST { {path = 'a.lua', content = [[ +---"hello world" this is ok +---@param bar any "lorem ipsum" this is ignored +---@param baz any # "dolor sit" this is ignored +local function <?foo?>(bar, baz) +end +]]}, +hover = [[ +```lua +function foo(bar: any, baz: any) +``` + +--- + +"hello world" this is ok + +@*param* `bar` — "lorem ipsum" this is ignored + +@*param* `baz` — "dolor sit" this is ignored]] +} diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index 4abe5855..18e7190d 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -1238,6 +1238,23 @@ local arr2 = { } ]] +TEST [[ +---@class A + +---@class B : A + +---@class C : B + +---@class D : B + +---@param x A +local function func(x) end + +---@type C|D +local var +func(var) +]] + config.remove(nil, 'Lua.diagnostics.disable', 'unused-local') config.remove(nil, 'Lua.diagnostics.disable', 'unused-function') config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global') diff --git a/test/hover/init.lua b/test/hover/init.lua index 7521ddf4..e77d8c98 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -238,14 +238,14 @@ TEST [[ string.<?sub?>() ]] [[ -function string.sub(s: string, i: integer, j?: integer) +function string.sub(s: string|number, i: integer, j?: integer) -> string ]] TEST[[ ('xx'):<?sub?>() ]] -[[function string.sub(s: string, i: integer, j?: integer) +[[function string.sub(s: string|number, i: integer, j?: integer) -> string]] TEST [[ @@ -272,7 +272,7 @@ TEST [[ string.<?lower?>() ]] [[ -function string.lower(s: string) +function string.lower(s: string|number) -> string ]] diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 597fb761..51de9cd5 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -178,7 +178,7 @@ TEST 'boolean' [[ <?x?> = a == b ]] -TEST 'integer' [[ +TEST 'unknown' [[ <?x?> = a << b ]] @@ -186,7 +186,7 @@ TEST 'integer' [[ <?x?> = 1 << 2 ]] -TEST 'string' [[ +TEST 'unknown' [[ <?x?> = a .. b ]] @@ -202,7 +202,7 @@ TEST 'string' [[ <?x?> = 'a' .. 1.0 ]] -TEST 'number' [[ +TEST 'unknown' [[ <?x?> = a + b ]] @@ -227,11 +227,11 @@ local a <?x?> = - a ]] -TEST 'integer' [[ +TEST 'unknown' [[ <?x?> = 1 + X ]] -TEST 'number' [[ +TEST 'unknown' [[ <?x?> = 1.0 + X ]] @@ -2416,7 +2416,7 @@ local <?z?> = f() TEST 'integer|table' [[ local function returnI() - return a + 1 + return 1 end local function f() @@ -4239,3 +4239,32 @@ TEST 'number' [[ local n local <?v?> = n or error('') ]] + +TEST 'Foo' [[ +---@class Foo +---@operator mul(Foo): Foo +---@operator mul(Bar): Foo +---@class Bar + +---@type Foo +local foo + +---@type Foo|Bar +local fooOrBar + +local <?b?> = foo * fooOrBar +]] + +TEST 'number' [[ +local a = 4; +local b = 2; + +local <?c?> = a / b; +]] + +TEST 'string' [[ +local a = '4'; +local b = '2'; + +local <?c?> = a .. b; +]] |