diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-10 15:56:47 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-10 15:56:47 +0800 |
commit | f335c413a409c1f03e379d7d5e1d5b377d378a0f (patch) | |
tree | 7c419f86b7bdfc5123f400cb48e8d100dea2ff1e /test/basic | |
parent | ea41c81ed7290827be63b58e61cf2334b41beace (diff) | |
download | lua-language-server-f335c413a409c1f03e379d7d5e1d5b377d378a0f.zip |
cleanup
Diffstat (limited to 'test/basic')
-rw-r--r-- | test/basic/init.lua | 1 | ||||
-rw-r--r-- | test/basic/linker.txt | 141 | ||||
-rw-r--r-- | test/basic/noder.lua | 143 |
3 files changed, 0 insertions, 285 deletions
diff --git a/test/basic/init.lua b/test/basic/init.lua index 1b698493..8490d51c 100644 --- a/test/basic/init.lua +++ b/test/basic/init.lua @@ -1,2 +1 @@ require 'basic.textmerger' -require 'basic.noder' diff --git a/test/basic/linker.txt b/test/basic/linker.txt deleted file mode 100644 index ea3ba180..00000000 --- a/test/basic/linker.txt +++ /dev/null @@ -1,141 +0,0 @@ -ast -> linkers = { - ['g|"X"|"Y"|"Z"'] = {src1, src2, src3}, - ['g|"X"|"Y"'] = {src4, src5, src6}, - ['g|"X"'] = {src7, src8, src9}, - ['l|7'] = {src10}, - ['l|7|"x"'] = {src11}, - ['l|11|"k"'] = {src12}, -} - -```lua -x.y.<?z?> = <!f!> - -<?g?> = x.y.z - -t.<!z!> = 1 -x.y = t - -x = { - y = { - <!z!> = 1 - } -} -``` - -expect: 'l|x|y|z' -forward: 'l|x|y|z' -> f -backward: 'l|x|y|z' -> g -last: 'l|x|y' + 'z' - -expect: 'l|x|y' + '|z' -forward: 'l|t' + '|z' -> 'l|t|z' -> t.z -backward: nil -last: 'l|x' + '|y|z' - -expect: 'l|x' + '|y|z' -forward: 'l|0' + '|y|z' -> 'l|0|y|z' -backward: nil -last: nil - -expect: 'l|0|y|z' -forward: nil -backward: nil -last: 'l|0|y' + '|z' - -expect: 'l|0|y' + '|z' -forward: 'l|1'+ '|z' -> 'l|1|z' -> field z -backward: nil -last: 'l|0' + '|y|z' - - -```lua -a = { - b = { - <?c?> = 1, - } -} - -print(a.b.<!c!>) -``` - -expect: 't|3|c' -forward: nil -backward: nil -last: 't|3' + '|c' - -expect: 't|3' + '|c' -forward: nil -backward: 't|2|b' + '|c' -last: nil - -expect: 't|2|b|c' -forward: nil -backward: 't|2|b' + '|c' -last: nil - -```lua ----@return <?A?> -local function f() -end - -local <!x!> = f() -``` - -'d|A' -'f|1|#1' -'f|1' + '|#1' -'l|1' + '|#1' -'s|1' + '|#1' - -```lua ----@generic T ----@param a T ----@return T -local function f(a) end - -local <?c?> - -local <!v!> = f(c) -``` - -'l1' -'l2|@1' -'f|1|@1' -'f|1|#1' - -``` ----@generic T ----@param p T ----@return T -local function f(p) end - -local <?r?> = f(<!k!>) -``` - -l:r -s:1#1 call -l:f#1 call -f:1#1 call -> f:1&T = l:k -l:f@1 --> 从保存的call信息里找到 f:1&T = l:k -l:k - - - -``` ----@generic T, V ----@param p T ----@return fun(V):T, V -local function f(p) end - -local f2 = f(<!k!>) -local <?r?> = f2() -``` - -l:r -s:2|#1 call1 -l:f2|#1 call1 -f:2|#1 call1 -s:1#1|#1 call2 -f:1#1|#1 call2 -> f:1&T = l:k -dfun:1|#1 -dn:V -> f:1&T = l:k diff --git a/test/basic/noder.lua b/test/basic/noder.lua deleted file mode 100644 index 49585ee8..00000000 --- a/test/basic/noder.lua +++ /dev/null @@ -1,143 +0,0 @@ -local noder = require 'core.noder' -local files = require 'files' -local util = require 'utility' -local guide = require 'parser.guide' -local catch = require 'catch' - -local function getSource(pos) - local ast = files.getState('') - return guide.eachSourceContain(ast.ast, pos, function (source) - if source.type == 'local' - or source.type == 'getlocal' - or source.type == 'setlocal' - or source.type == 'setglobal' - or source.type == 'getglobal' - or source.type == 'setfield' - or source.type == 'getfield' - or source.type == 'setmethod' - or source.type == 'getmethod' - or source.type == 'tablefield' - or source.type == 'setindex' - or source.type == 'getindex' - or source.type == 'tableindex' - or source.type == 'label' - or source.type == 'goto' then - return source - end - end) -end - -local CARE = {} -local function TEST(script) - return function (expect) - local newScript, catched = catch(script, '?') - files.setText('', newScript) - local source = getSource(catched['?'][1][1]) - assert(source) - local result = { - id = noder.getID(source), - } - - expect['id'] = expect['id']:gsub('|', '\x1F') - - for key in pairs(CARE) do - assert(result[key] == expect[key]) - end - files.remove('') - end -end - -CARE['id'] = true -TEST [[ -local <?x?> -]] { - id = 'l:6', -} - -TEST [[ -local x -print(<?x?>) -]] { - id = 'l:6', -} - -TEST [[ -local x -<?x?> = 1 -]] { - id = 'l:6', -} - -TEST [[ -print(<?X?>) -]] { - id = 'g:.X', -} - -TEST [[ -print(<?X?>) -]] { - id = 'g:.X', -} - -TEST [[ -local x -print(x.y.<?z?>) -]] { - id = 'l:6|.y|.z', -} - -TEST [[ -local x -function x:<?f?>() end -]] { - id = 'l:6|.f', -} - -TEST [[ -print(X.Y.<?Z?>) -]] { - id = 'g:.X|.Y|.Z', -} - -TEST [[ -function x:<?f?>() end -]] { - id = 'g:.x|.f', -} - -TEST [[ -{ - <?x?> = 1, -} -]] { - id = 't:0|.x', -} - -TEST [[ -return <?X?> -]] { - id = 'g:.X', -} - -TEST [[ -function f() - return <?X?> -end -]] { - id = 'g:.X', -} - -TEST [[ -::<?label?>:: -goto label -]] { - id = 'l:2', -} - -TEST [[ -::label:: -goto <?label?> -]] { - id = 'l:2', -} |