diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:08:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:08:02 +0800 |
commit | 4b085b8aea5f33ec114baa31d2b9d72341383c32 (patch) | |
tree | fe35a326408e762711a31d3e803464f0c1a8468d /test/basic/noder.lua | |
parent | 0c8c6bbf23082d0b858646846a47a3001f718ae2 (diff) | |
parent | 35ce57976db3b4c42193279dd55972ea013fecad (diff) | |
download | lua-language-server-4b085b8aea5f33ec114baa31d2b9d72341383c32.zip |
Merge branch 'newparser'
Diffstat (limited to 'test/basic/noder.lua')
-rw-r--r-- | test/basic/noder.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/test/basic/noder.lua b/test/basic/noder.lua index bc572a4c..87b34e12 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 finish = 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 <?x?> ]] { - id = 'l:9', + id = 'l:6', } TEST [[ local x print(<?x?>) ]] { - id = 'l:7', + id = 'l:6', } TEST [[ local x <?x?> = 1 ]] { - id = 'l:7', + id = 'l:6', } TEST [[ @@ -86,14 +84,14 @@ TEST [[ local x print(x.y.<?z?>) ]] { - id = 'l:7|.y|.z', + id = 'l:6|.y|.z', } TEST [[ local x function x:<?f?>() end ]] { - id = 'l:7|.f', + id = 'l:6|.f', } TEST [[ @@ -113,7 +111,7 @@ TEST [[ <?x?> = 1, } ]] { - id = 't:1|.x', + id = 't:0|.x', } TEST [[ @@ -134,12 +132,12 @@ TEST [[ ::<?label?>:: goto label ]] { - id = 'l:5', + id = 'l:2', } TEST [[ ::label:: goto <?label?> ]] { - id = 'l:3', + id = 'l:2', } |