diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-08-11 16:28:47 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-08-11 17:57:29 +0800 |
commit | 6fe0ea884f692a460cdf084c28900fc44dec0018 (patch) | |
tree | 68fdfcf8bdaf3c18ab06af2a7a32d6eb3fc1c809 /test/diagnostics/common.lua | |
parent | 736e54a8ecaada2dacd0fd0ae35ad03aa75a7149 (diff) | |
download | lua-language-server-6fe0ea884f692a460cdf084c28900fc44dec0018.zip |
cleanup tests
Diffstat (limited to 'test/diagnostics/common.lua')
-rw-r--r-- | test/diagnostics/common.lua | 443 |
1 files changed, 0 insertions, 443 deletions
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index e0a3e342..24ec4c8c 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -1,455 +1,12 @@ local config = require 'config' local util = require 'utility' -TEST [[ -local function x(a, b) - return a, b -end -x(1) -]] - -TEST [[ ----@param a integer ----@param b integer -local function x(a, b) - return a, b -end -<!x(1)!> -]] - -TEST [[ ----@param a integer ----@param b integer -local function x(a, b) - return a, b -end -<!x()!> -]] - -TEST [[ ----@param a integer ----@param b integer ----@param ... integer -local function x(a, b, ...) - return a, b, ... -end -x(1, 2) -]] - -TEST [[ ----@param a integer ----@param b integer -local function f(a, b) -end - -f(...) -]] - -TEST [[ ----@param a integer ----@param b integer -local function f(a, b) -end - -local function return2Numbers() - return 1, 2 -end - -f(return2Numbers()) -]] - -TEST [[ ----@param a integer ----@param b? integer -local function x(a, b) - return a, b -end -x(1) -]] - -TEST [[ ----@param b integer? -local function x(a, b) - return a, b -end -x(1) -]] - -TEST [[ ----@param b integer|nil -local function x(a, b) - return a, b -end -x(1) -]] - -TEST [[ -local m = {} -function m.x() -end -m:x() -]] - -TEST [[ -InstanceName = 1 -Instance = _G[InstanceName] -]] - -TEST [[ -local _ = (''):sub(1, 2) -]] - -TEST [=[ -return [[ - -]] -]=] - -util.arrayInsert(disables, 'close-non-object') -TEST [[ -local _ <close> = function () end -]] -util.arrayRemove(disables, 'close-non-object') - -TEST [[ -local _ <close> = <!1!> -]] - -TEST [[ -local _ <close> = <!''!> -]] - -TEST [[ -local c <close> = <!(function () return 1 end)()!> -]] - -util.arrayInsert(disables, 'unused-local') -TEST [[ -local f = <!function () end!> -]] - -TEST [[ -local f;f = <!function () end!> -]] - -TEST [[ -local <!function f() end!> -]] - -TEST [[ -local <!function f() - f() -end!> -]] - - -TEST [[ -local <!function test() -end!> - -local <!function foo () -end!> -]] - -util.arrayRemove(disables, 'unused-local') -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(<!...!>) - return 'something' -end -f() -]] - -TEST [[ -local function f(var) - print(var) -end -local var -f(var) -]] - -TEST [[ -local function f(a, b) - return a, b -end -f(1, 2, <!3!>, <!4!>) -]] - -TEST [[ -local mt = {} -function mt:f(a, b) - return a, b -end -mt.f(mt, 2, 3, <!4!>) -]] - - -TEST [[ -local mt = {} -function mt.f(a, b) - return a, b -end -mt:f(1, <!2!>, <!3!>, <!4!>) -]] - -TEST [[ -local mt = {} -function mt:f(a, b) - return a, b -end -mt:f(1, 2, <!3!>, <!4!>) -]] - -TEST [[ -local function f(a, b, ...) - return a, b, ... -end -f(1, 2, 3, 4) -]] - -TEST [[ -local _ = next({}, 1, <!2!>) -print(1, 2, 3, 4, 5) -]] - -TEST [[ -local function f(callback) - callback(1, 2, 3) -end -f(function () end) -]] - ---TEST [[ ---local realTostring = tostring ---tostring = function () end ---tostring(<!1!>) ---tostring = realTostring ---tostring(1) ---]] - -TEST [[ -<!aa!> = 1 -tostring = 1 -ROOT = 1 -_G.bb = 1 -]] - -TEST [[ -local f = load('') -if f then - f(1, 2, 3) -end -]] - -TEST [[ -local _ = <!unpack!> -]] - -TEST [[ -X = table[<!x!>] -]] - -TEST [[ -return { - <!x!> = 1, - y = 2, - <!x!> = 3, -} -]] -TEST [[ -return { - x = 1, - y = 2, -}, { - x = 1, - y = 2, -} -]] - -TEST [[ -local m = {} -function m.open() -end - -m:open() -]] - -TEST [[ -local m = {} -function m:open() -end -m.open(m) -]] -TEST [[ -<!if true then -end!> -]] -TEST [[ -<!if true then -else -end!> -]] -TEST [[ -if true then -else - return -end -]] -TEST [[ -while true do -end -]] - -TEST [[ -<!for _ = 1, 10 do -end!> -]] - -TEST [[ -<!for _ in pairs({}) do -end!> -]] - -TEST [[ -local _ = 1, <!2!> -]] - -TEST [[ -_ = 1, <!2!> -]] - -TEST [[ -function X() - do - local k - print(k) - end - local k = 1 - print(k) -end -]] - -TEST [[ -function X() - local loc - print(loc) -end -]] - -TEST [[ -local <!t!> = {} -<!t!>[1] = 1 -]] - -TEST [[ -T1 = 1 -_ENV.T2 = 1 -_G.T3 = 1 -_ENV._G.T4 = 1 -_G._G._G.T5 = 1 -rawset(_G, 'T6', 1) -rawset(_ENV, 'T7', 1) -print(T1) -print(T2) -print(T3) -print(T4) -print(T5) -print(T6) -print(T7) -]] - -TEST [[ -local x -x = <!x or 0 + 1!> -]] - -TEST [[ -local x, y -x = <!x + y or 0!> -]] - -TEST [[ -local x, y, z -x = x and y or '' .. z -]] - -TEST [[ -local x -x = x or -1 -]] - -TEST [[ -local x -x = x or (0 + 1) -]] - -TEST [[ -local x, y -x = (x + y) or 0 -]] - -TEST [[ -local t = {} -t.a = 1 -t.a = 2 -return t -]] - -TEST [[ -table.insert({}, 1, 2, <!3!>) -]] - -TEST [[ -while true do - break - <!print() - print()!> -end -]] TEST [[ local x, <!y!>, <!z!> = 1 |