diff options
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 |