diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-29 09:56:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-29 09:56:54 +0800 |
commit | 79d073d7b3ae2f508f0d2e154ed59f87530740e7 (patch) | |
tree | dfc428c3ca49671435c2e2a99889c97a2f505950 /server/test | |
parent | 9d2265692897472cb1efc3891ef89fe3a58126b0 (diff) | |
download | lua-language-server-79d073d7b3ae2f508f0d2e154ed59f87530740e7.zip |
换成新的parser
Diffstat (limited to 'server/test')
-rw-r--r-- | server/test/definition/init.lua | 5 | ||||
-rw-r--r-- | server/test/implementation/init.lua | 6 | ||||
-rw-r--r-- | server/test/main.lua | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/server/test/definition/init.lua b/server/test/definition/init.lua index b88cfeef..8bf2411d 100644 --- a/server/test/definition/init.lua +++ b/server/test/definition/init.lua @@ -1,4 +1,5 @@ local matcher = require 'matcher' +local parser = require 'parser' rawset(_G, 'TEST', true) @@ -7,8 +8,10 @@ function TEST(script) local finish = script:find('!>', 1, true) - 1 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(new_script, pos) + local suc, a, b = matcher.definition(ast, pos) assert(suc) assert(a == start) assert(b == finish) diff --git a/server/test/implementation/init.lua b/server/test/implementation/init.lua index de8d9d63..94db86fc 100644 --- a/server/test/implementation/init.lua +++ b/server/test/implementation/init.lua @@ -1,4 +1,5 @@ local matcher = require 'matcher' +local parser = require 'parser' rawset(_G, 'TEST', true) @@ -42,8 +43,9 @@ function TEST(script) local target = catch_target(script) local pos = script:find('<?', 1, true) + 2 local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') - - local suc, result = matcher.implementation(new_script, pos) + local ast, err = parser:ast(new_script) + assert(ast) + local suc, result = matcher.implementation(ast, pos) assert(suc) assert(founded(target, result)) end diff --git a/server/test/main.lua b/server/test/main.lua index 4fbf7339..089f59b8 100644 --- a/server/test/main.lua +++ b/server/test/main.lua @@ -21,7 +21,7 @@ local function main() end test 'definition' - test 'implementation' + --test 'implementation' print('测试完成') end |