summaryrefslogtreecommitdiff
path: root/server-beta/test/highlight
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-16 03:02:01 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-16 03:02:01 +0800
commit81fb889cbf994be47f162dbfda446f80e51c6fab (patch)
tree3bf11ab96b180000e3228ea16188d1d888475df8 /server-beta/test/highlight
parentf2c235601da54117b803e084d94bbf88ba53b891 (diff)
downloadlua-language-server-81fb889cbf994be47f162dbfda446f80e51c6fab.zip
支持高亮
Diffstat (limited to 'server-beta/test/highlight')
-rw-r--r--server-beta/test/highlight/init.lua99
1 files changed, 76 insertions, 23 deletions
diff --git a/server-beta/test/highlight/init.lua b/server-beta/test/highlight/init.lua
index 6298fc2e..fbde194b 100644
--- a/server-beta/test/highlight/init.lua
+++ b/server-beta/test/highlight/init.lua
@@ -35,58 +35,111 @@ local function founded(targets, results)
end
function TEST(script)
- files.removeAll()
local target = catch_target(script)
- local start = script:find('<?', 1, true)
- local finish = script:find('?>', 1, true)
- local pos = (start + finish) // 2 + 1
- local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- files.setText('', new_script)
-
- local positions = core('', pos)
- if positions then
- assert(founded(target, positions))
- else
- assert(#target == 0)
+ for _, enter in ipairs(target) do
+ local start, finish = enter.start, enter.finish
+ files.removeAll()
+ local pos = (start + finish) // 2 + 1
+ local new_script = script:gsub('<[!?~]', ' '):gsub('[!?~]>', ' ')
+ files.setText('', new_script)
+
+ local positions = core('', pos)
+ if positions then
+ assert(founded(target, positions))
+ else
+ assert(#target == 0)
+ end
end
end
TEST [[
-local <?a?> = 1
+local <!a!> = 1
]]
TEST [[
-local <?a?> = 1
+local <!a!> = 1
<!a!> = 2
<!a!> = <!a!>
]]
TEST [[
-t.<?a?> = 1
+t.<!a!> = 1
a = t.<!a!>
]]
TEST [[
t[<!'a'!>] = 1
-a = t.<?a?>
-]]
-
-TEST [[
-t[<?'a'?>] = 1
a = t.<!a!>
]]
TEST [[
-:: <?a?> ::
+:: <!a!> ::
goto <!a!>
]]
TEST [[
local function f(<!a!>)
- return <?a?>
+ return <!a!>
end
]]
TEST [[
-local s = <?'asd/gadasd.fad.zxczg'?>
+local s = <!'asd/gadasd.fad.zxczg'!>
+]]
+
+TEST [[
+local b = <!true!>
+]]
+
+TEST [[
+local n = <!nil!>
+]]
+
+TEST [[
+local n = <!1.2354!>
+]]
+
+TEST [[
+local <!function!> f () <!end!>
+]]
+
+TEST [[
+<!function!> f () <!end!>
+]]
+
+TEST [[
+return <!function!> () <!end!>
+]]
+
+TEST [[
+<!if!> true <!then!>
+<!elseif!> true <!then!>
+<!elseif!> true <!then!>
+<!else!>
+<!end!>
+]]
+
+TEST [[
+<!for!> _ <!in!> _ <!do!>
+<!end!>
+]]
+
+TEST [[
+<!for!> i = 1, 10 <!do!>
+<!end!>
+]]
+
+TEST [[
+<!while!> true <!do!>
+<!end!>
+]]
+
+TEST [[
+<!repeat!>
+<!until!> true
+]]
+
+TEST [[
+<!do!>
+<!end!>
]]