From 4d1b606cc875803cc07031c63cde351300ea664a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 14 Sep 2021 19:32:31 +0800 Subject: update --- test/basic/noder.lua | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'test/basic') diff --git a/test/basic/noder.lua b/test/basic/noder.lua index bc572a4c..4c0a1620 100644 --- a/test/basic/noder.lua +++ b/test/basic/noder.lua @@ -2,6 +2,7 @@ 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('') @@ -30,12 +31,9 @@ local CARE = {} local function TEST(script) return function (expect) files.removeAll() - local start = script:find('', 1, true) - local pos = (start + finish) // 2 + 1 - local newScript = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ') + local newScript, catched = catch(script, '?') files.setText('', newScript) - local source = getSource(pos) + local source = getSource(catched[1][1]) assert(source) local result = { id = noder.getID(source), @@ -53,21 +51,21 @@ CARE['id'] = true TEST [[ local ]] { - id = 'l:9', + id = 'l:6', } TEST [[ local x print() ]] { - id = 'l:7', + id = 'l:6', } TEST [[ local x = 1 ]] { - id = 'l:7', + id = 'l:6', } TEST [[ @@ -86,14 +84,14 @@ TEST [[ local x print(x.y.) ]] { - id = 'l:7|.y|.z', + id = 'l:6|.y|.z', } TEST [[ local x function x:() end ]] { - id = 'l:7|.f', + id = 'l:6|.f', } TEST [[ @@ -113,7 +111,7 @@ TEST [[ = 1, } ]] { - id = 't:1|.x', + id = 't:0|.x', } TEST [[ @@ -134,12 +132,12 @@ TEST [[ :::: goto label ]] { - id = 'l:5', + id = 'l:2', } TEST [[ ::label:: goto ]] { - id = 'l:3', + id = 'l:2', } -- cgit v1.2.3