summaryrefslogtreecommitdiff
path: root/server/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-11-29 16:55:59 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-11-29 16:55:59 +0800
commit9992c649cde19d4db8c9a9a7b47eb71bb2eaa283 (patch)
tree1c85e8f75ad10c9c5febea94d837a5cfce773072 /server/test
parentb13e39260cc47b90c9b5b095964ea56c1a3d7cd5 (diff)
downloadlua-language-server-9992c649cde19d4db8c9a9a7b47eb71bb2eaa283.zip
除了表以外的转到定义能用了
Diffstat (limited to 'server/test')
-rw-r--r--server/test/definition/bug.lua17
-rw-r--r--server/test/definition/init.lua20
2 files changed, 30 insertions, 7 deletions
diff --git a/server/test/definition/bug.lua b/server/test/definition/bug.lua
index b0e890ca..4ad2a05a 100644
--- a/server/test/definition/bug.lua
+++ b/server/test/definition/bug.lua
@@ -3,7 +3,7 @@ local <!x!>
function _(x)
end
function _()
- <?x?>
+ <?x?>()
end
]]
@@ -13,3 +13,18 @@ function _(<!x!>)
<?x?> = 1
end
]]
+
+TEST [[
+function a<!:!>b()
+ a:b()
+ <?self?>()
+end
+]]
+
+TEST [[
+function _(...)
+ function _()
+ print(<?...?>)
+ end
+end
+]]
diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua
index 8bf2411d..17c23b0e 100644
--- a/server/test/definition/init.lua
+++ b/server/test/definition/init.lua
@@ -4,22 +4,30 @@ local parser = require 'parser'
rawset(_G, 'TEST', true)
function TEST(script)
- local start = script:find('<!', 1, true) + 2
- local finish = script:find('!>', 1, true) - 1
+ local start = script:find('<!', 1, true)
+ local finish = script:find('!>', 1, true)
+ if start and finish then
+ start = start + 2
+ finish = finish - 1
+ end
local pos = script:find('<?', 1, true) + 2
local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
local ast, err = parser:ast(new_script)
assert(ast)
local suc, a, b = matcher.definition(ast, pos)
- assert(suc)
- assert(a == start)
- assert(b == finish)
+ if start and finish then
+ assert(suc == true)
+ assert(a == start)
+ assert(b == finish)
+ else
+ assert(suc == false)
+ end
end
require 'definition.set'
require 'definition.local'
require 'definition.arg'
require 'definition.function'
-require 'definition.table'
+--require 'definition.table'
require 'definition.bug'