diff options
Diffstat (limited to 'server/test/definition')
-rw-r--r-- | server/test/definition/arg.lua | 19 | ||||
-rw-r--r-- | server/test/definition/bug.lua | 90 | ||||
-rw-r--r-- | server/test/definition/emmy.lua | 91 | ||||
-rw-r--r-- | server/test/definition/function.lua | 24 | ||||
-rw-r--r-- | server/test/definition/init.lua | 64 | ||||
-rw-r--r-- | server/test/definition/label.lua | 29 | ||||
-rw-r--r-- | server/test/definition/local.lua | 195 | ||||
-rw-r--r-- | server/test/definition/method.lua | 140 | ||||
-rw-r--r-- | server/test/definition/set.lua | 50 | ||||
-rw-r--r-- | server/test/definition/table.lua | 114 |
10 files changed, 0 insertions, 816 deletions
diff --git a/server/test/definition/arg.lua b/server/test/definition/arg.lua deleted file mode 100644 index 9e88b2bf..00000000 --- a/server/test/definition/arg.lua +++ /dev/null @@ -1,19 +0,0 @@ -TEST [[ -local function xx (<!xx!>) - <?xx?>() -end -]] - -TEST [[ -local <!mt!> -function mt:x() - <?self?>() -end -mt:x() -]] - -TEST [[ -function mt:x(<!self!>) - <?self?>() -end -]] diff --git a/server/test/definition/bug.lua b/server/test/definition/bug.lua deleted file mode 100644 index 1d3ab02c..00000000 --- a/server/test/definition/bug.lua +++ /dev/null @@ -1,90 +0,0 @@ -TEST [[ -local <!x!> -function _(x) -end -function _() - <?x?>() -end -]] - -TEST [[ -function _(<!x!>) - do return end - <?x?>() -end -]] - -TEST [[ -local <!a!> -function a:b() - a:b() - <?self?>() -end -]] - -TEST [[ -function _(...) - function _() - print(<?...?>) - end -end -]] - -TEST [[ -local <!a!> -(<?a?> / b)() -]] - -TEST [[ -local <!args!> -io.load(root / <?args?>.source / 'API' / path) -]] - -TEST [[ -obj[#<?obj?>+1] = {} -]] - -TEST [[ -self = { - results = { - <!labels!> = {}, - } -} -self[self.results.<?labels?>] = lbl -]] - -TEST [[ -local mt = {} -function mt:<!x!>() -end -mt:x() -mt:<?x?>() -]] - -TEST [[ -local function func(<!a!>) - x = { - xx(), - <?a?>, - } -end -]] - -TEST [[ -local <!x!> -local t = { - ..., - <?x?>, -} -]] - -TEST [[ -local a -local <!b!> -return f(), <?b?> -]] - -TEST [[ -local a = os.clock() -local <?<!b!>?> = os.clock() -]] diff --git a/server/test/definition/emmy.lua b/server/test/definition/emmy.lua deleted file mode 100644 index ee8fa6a7..00000000 --- a/server/test/definition/emmy.lua +++ /dev/null @@ -1,91 +0,0 @@ -TEST [[ ----@class <!A!> ----@class B : <?A?> -]] - -TEST [[ ----@class <!A!> ----@type B|<?A?> -]] - -TEST [[ ----@class A -local mt = {} -function mt:<!cast!>() -end - ----@type A -local obj -obj:<?cast?>() -]] - -TEST [[ ----@class A -local <!mt!> = {} -function mt:cast() -end - ----@type A -local <!obj!> -<?obj?>:cast() -]] - -TEST [[ ----@type A -local <?<!obj!>?> - ----@class A -local <!mt!> -]] - -TEST [[ ----@type A -local obj -obj:<?func?>() - ----@class A -local mt -function mt:<!func!>() -end -]] - -TEST [[ ----@type A -local obj -obj:<?func?>() - -local mt = {} -mt.__index = mt -function mt:<!func!>() -end ----@class A -local obj = setmetatable({}, mt) -]] - -TEST [[ ----@alias <!B A!> ----@type <?B?> -]] - -TEST [[ ----@class <!Class!> ----@param a <?Class?> -]] - -TEST [[ ----@class Class ----@field <!name string!> ----@field id integer -local mt = {} -mt.<?name?> -]] - -TEST [[ ----@class loli -local unit - -function unit:<!pants!>() -end - ----@see loli#<?pants?> -]] diff --git a/server/test/definition/function.lua b/server/test/definition/function.lua deleted file mode 100644 index ce20f50b..00000000 --- a/server/test/definition/function.lua +++ /dev/null @@ -1,24 +0,0 @@ - -TEST [[ -function <!x!> () end -<?x?>() -]] - -TEST [[ -local function <!x!> () end -<?x?>() -]] - -TEST [[ -local x -local function <!x!> () - <?x?>() -end -]] - -TEST [[ -local <!x!> -function <!x!>() -end -<?x?>() -]] diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua deleted file mode 100644 index 022b1d3b..00000000 --- a/server/test/definition/init.lua +++ /dev/null @@ -1,64 +0,0 @@ -local core = require 'core' -local parser = require 'parser' -local buildVM = require 'vm' - -rawset(_G, 'TEST', true) - -local function catch_target(script) - local list = {} - local cur = 1 - while true do - local start, finish = script:find('<!.-!>', cur) - if not start then - break - end - list[#list+1] = { start + 2, finish - 2 } - cur = finish + 1 - end - return list -end - -local function founded(targets, results) - if #targets ~= #results then - return false - end - for _, target in ipairs(targets) do - for _, result in ipairs(results) do - if target[1] == result[1] and target[2] == result[2] then - goto NEXT - end - end - do return false end - ::NEXT:: - end - return true -end - -function TEST(script) - local target = catch_target(script) - local start = script:find('<?', 1, true) - local finish = script:find('?>', 1, true) - local pos = (start + finish) // 2 + 1 - local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') - local ast = parser:parse(new_script, 'lua', 'Lua 5.3') - assert(ast) - local vm = buildVM(ast) - assert(vm) - - local positions = core.definition(vm, pos, 'definition') - if positions then - assert(founded(target, positions)) - else - assert(#target == 0) - end -end - -require 'definition.set' -require 'definition.local' -require 'definition.arg' -require 'definition.function' -require 'definition.table' -require 'definition.method' -require 'definition.label' -require 'definition.bug' -require 'definition.emmy' diff --git a/server/test/definition/label.lua b/server/test/definition/label.lua deleted file mode 100644 index 4859d70e..00000000 --- a/server/test/definition/label.lua +++ /dev/null @@ -1,29 +0,0 @@ -TEST [[ -::<!LABEL!>:: -goto <?LABEL?> -]] - -TEST [[ -goto <?LABEL?> -::<!LABEL!>:: -]] - -TEST [[ -::LABEL:: -function _() - goto <?LABEL?> -end -]] - -TEST [[ -do - goto <?LABEL?> -end -::<!LABEL!>:: -]] - -TEST [[ -::<!LABEL!>:: -goto <?LABEL?> -::<!LABEL!>:: -]] diff --git a/server/test/definition/local.lua b/server/test/definition/local.lua deleted file mode 100644 index 4153bfa0..00000000 --- a/server/test/definition/local.lua +++ /dev/null @@ -1,195 +0,0 @@ -TEST [[ -local <!x!> -<?x?>() -]] - -TEST [[ -local z, y, <!x!> -<?x?>() -]] - -TEST [[ -local <!x!> = 1 -<?x?>() -]] - -TEST [[ -local z, y, <!x!> = 1 -<?x?>() -]] - -TEST [[ -local x -local <!x!> -<?x?>() -]] - -TEST [[ -local <!x!> -do - <?x?>() -end -]] - -TEST [[ -local <!x!> -do - local x -end -<?x?>() -]] - -TEST [[ -local <!x!> -if <?x?> then - local x -end -]] - -TEST [[ -local <!x!> -if x then - local x -elseif <?x?> then - local x -end -]] - -TEST [[ -local <!x!> -if x then - local x -elseif x then - local x -else - local x -end -<?x?>() -]] - -TEST [[ -local <!x!> -if x then - <?x?>() -elseif x then - local x -else - local x -end -]] - -TEST [[ -local <!x!> -for x = 1, 10 do -end -<?x?>() -]] - -TEST [[ -local x -for <!x!> = 1, 10 do - <?x?>() -end -]] - -TEST [[ -local <!x!> -for x in x do -end -<?x?>() -]] - -TEST [[ -local <!x!> -for x in <?x?> do -end -]] - -TEST [[ -local x -for <!x!> in x do - <?x?>() -end -]] - -TEST [[ -local x -for z, y, <!x!> in x do - <?x?>() -end -]] - -TEST [[ -local <!x!> -while <?x?> do -end -]] - -TEST [[ -local <!x!> -while x do - <?x?>() -end -]] - -TEST [[ -local <!x!> -while x do - local x -end -<?x?>() -]] - -TEST [[ -local <!x!> -repeat - <?x?>() -until true -]] - -TEST [[ -local <!x!> -repeat - local x -until true -<?x?>() -]] - -TEST [[ -local <!x!> -repeat -until <?x?> -]] - -TEST [[ -local x -repeat - local <!x!> -until <?x?> -]] - -TEST [[ -local <!x!> -function _() - local x -end -<?x?>() -]] - -TEST [[ -local <!x!> -return function () - <?x?>() -end -]] - -TEST [[ -local <!x!> -local x = function () - <?x?>() -end -]] - -TEST [[ -local <?<!x!>?> -]] diff --git a/server/test/definition/method.lua b/server/test/definition/method.lua deleted file mode 100644 index 08b56f61..00000000 --- a/server/test/definition/method.lua +++ /dev/null @@ -1,140 +0,0 @@ -TEST [[ -function mt:<!a!>() -end -function mt:b() - mt:<?a?>() -end -]] - -TEST [[ -function mt:<!m1!>() -end -function mt:m2() - self:<?m1?>() -end -]] - -TEST [[ -function mt:m3() - mt:<?m4?>() -end -function mt:<!m4!>() -end -]] - -TEST [[ -function mt:m3() - self:<?m4?>() -end -function mt:<!m4!>() -end -]] - -TEST [[ -local mt -mt.__index = mt -function mt:<!method1!>() -end - -local obj = setmetatable({}, mt) -obj:<?method1?>() -]] - -TEST [[ -local mt -mt.__index = mt -function mt:<!method1!>() -end - -local obj = setmetatable({}, mt) -obj:<?method1?>() -]] - -TEST [[ -local mt -function mt:<!method1!>() -end - -local obj = setmetatable({}, { __index = mt }) -obj:<?method1?>() -]] - -TEST [[ -local mt -local api -function mt:<!method1!>() -end - -setmetatable(api, { __index = mt }) -api:<?method1?>() -]] - -TEST [[ -local mt -function mt:x() - self.<?init?>() -end - -local obj = setmetatable({}, { __index = mt }) -obj.<!init!> = 1 -obj:x() -]] - -TEST [[ -local mt -function mt:x() - self.<?init?>() -end - -local obj = setmetatable({ <!init!> = 1 }, { __index = mt }) -obj:x() -]] - -TEST [[ -local mt -function mt:x() - self.a.<?out?>() -end - -local obj = setmetatable({ - a = { - <!out!> = 1, - } -}, { __index = mt }) -obj:x() -]] - -TEST [[ -local sm = setmetatable -local mt -mt.__index = mt -function mt:<!method1!>() -end - -local obj = sm({}, mt) -obj:<?method1?>() -]] - -TEST [[ -local mt = {} -function mt:<!x!>() -end - -local obj = setmetatable({}, {__index = mt}) -function obj:x() -end - -mt:<?x?>() -]] - -TEST [[ -local mt = {} -function mt:x() -end - -local obj = setmetatable({}, {__index = mt}) -function obj:<!x!>() -end - -obj:<?x?>() -]] diff --git a/server/test/definition/set.lua b/server/test/definition/set.lua deleted file mode 100644 index 44277d33..00000000 --- a/server/test/definition/set.lua +++ /dev/null @@ -1,50 +0,0 @@ -TEST [[ -<!x!> = 1 -<?x?>() -]] - -TEST [[ -do - <!global!> = 1 -end -<?global?>() -]] - -TEST [[ -<!x!> = 1 -do - local x = 1 -end -<?x?>() -]] - -TEST [[ -x = 1 -do - local <!x!> = 1 - do - <!x!> = 2 - end - <?x?>() -end -]] - -TEST [[ -<!x!> = 1 -if y then - <!x!> = 2 -else - <!x!> = 3 -end -print(<?x?>) -]] - -TEST [[ -_G.<!x!> = 1 -print(<?x?>) -]] - -TEST [[ -rawset<!(_G, 'x', 1)!> -print(<?x?>) -]] diff --git a/server/test/definition/table.lua b/server/test/definition/table.lua deleted file mode 100644 index 90e7926f..00000000 --- a/server/test/definition/table.lua +++ /dev/null @@ -1,114 +0,0 @@ -TEST [[ -local <!t!> -a = { - <?t?> -} -]] - -TEST [[ -local t -t.<!x!> = 1 -t.<?x?>() -]] - -TEST [[ -t.<!x!> = 1 -t.<?x?>() -]] - -TEST [[ -local <!t!> -t.x = 1 -<?t?>.x = 1 -]] - -TEST [[ -t.<!x!> = 1 -t.<?x?>.y = 1 -]] - -TEST [[ -local t -t.<!x!> = 1 -t.<?x?>() -]] - -TEST [[ -local t -t[<!1!>] = 1 -t[<?1?>]() -]] - -TEST [[ -local t -t[<!true!>] = 1 -t[<?true?>]() -]] - -TEST [[ -local t -t[<!"method"!>] = 1 -t[<?"method"?>]() -]] - -TEST [[ -local t -t[<!"longString"!>] = 1 -t[<?[==[longString]==]?>]() -]] - -TEST [[ -local t -t.<!x!> = 1 -t[<?'x'?>]() -]] - -TEST [[ -local t -t.<!a!> = 1 -t.<?a?>.b() -]] - -TEST [[ -local t -local <!x!> -t[<?x?>]() -]] - -TEST[[ -local <!t!> -local _ = { - _ = <?t?> -} -]] - -TEST[[ -local <!t!> -t { - _ = <?t?>.x -} -]] - -TEST[[ -local t = { - <!insert!> = 1, -} -t.<?insert?>() -]] - ---TEST[[ ---local t = { --- <!insert!> = 1, ---} ---y.<?insert?>() ---]] - ---TEST[[ ---local t = { --- <!insert!> = 1, ---} ---local y = { --- insert = 1, ---} ---t.<?insert?>() ---]] |