diff options
author | fesily <fesil@foxmail.com> | 2024-01-10 11:03:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-10 11:03:21 +0800 |
commit | 1e7bb72ad3ff2b75a1c55ee4bc53004cb7fe30f7 (patch) | |
tree | dd94cf09b9e3a675a73a9f1d41248d1538165997 /test/diagnostics/unused-local.lua | |
parent | bb6e172d6166190bd4edd3bb56230a7d60ebcb93 (diff) | |
parent | 37779f9b2493e51e59e1e4366bf7dcb8350e69bd (diff) | |
download | lua-language-server-1e7bb72ad3ff2b75a1c55ee4bc53004cb7fe30f7.zip |
Merge branch 'LuaLS:master' into plugin-add-OnTransformAst
Diffstat (limited to 'test/diagnostics/unused-local.lua')
-rw-r--r-- | test/diagnostics/unused-local.lua | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/test/diagnostics/unused-local.lua b/test/diagnostics/unused-local.lua new file mode 100644 index 00000000..425f3e1e --- /dev/null +++ b/test/diagnostics/unused-local.lua @@ -0,0 +1,99 @@ +local config = require 'config' + +TEST [[ +local <!x!> +]] + +TEST [[ +local y +local x <close> = y +]] + +TEST [[ +local function x() +end +x() +]] + +TEST [[ +return function (x) + x.a = 1 +end +]] + +TEST [[ +local <!t!> = {} +<!t!>.a = 1 +]] + +TEST [[ +InstanceName = 1 +Instance = _G[InstanceName] +]] + +TEST [[ +local _ = (''):sub(1, 2) +]] + +TEST [[ +local mt, x +function mt:m() + function x:m() + end +end +return mt, x +]] + +TEST [[ +local mt = {} +function mt:f() +end +return mt +]] + +TEST [[ +local <!mt!> = {} +function <!mt!>:f() +end +]] + +TEST [[ +local <!x!> = {} +<!x!>.a = 1 +]] + +TEST [[ +local <!x!> = {} +<!x!>['a'] = 1 +]] + +TEST [[ +local function f(<!self!>) + return 'something' +end +f() +]] + +TEST [[ +local function f(var) + print(var) +end +local var +f(var) +]] + +TEST [[ +local <!t!> = {} +<!t!>[1] = 1 +]] + +config.add(nil, 'Lua.diagnostics.unusedLocalExclude', 'll_*') + +TEST [[ +local <!xx!> +local ll_1 +local ll_2 +local <!ll!> +]] + +config.remove(nil, 'Lua.diagnostics.unusedLocalExclude', 'll_*') |