summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-23 20:38:07 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-23 20:38:07 +0800
commit7ddc57e0f0a8b32d7d8bfa9228e856d897fc8de9 (patch)
treedce3b454d310f123631742aad664e370d36569a5 /test
parent5e6897bc1a25b936724af6eeb5fc463a8d395d1e (diff)
downloadlua-language-server-7ddc57e0f0a8b32d7d8bfa9228e856d897fc8de9.zip
update
Diffstat (limited to 'test')
-rw-r--r--test/type_formatting/init.lua74
1 files changed, 49 insertions, 25 deletions
diff --git a/test/type_formatting/init.lua b/test/type_formatting/init.lua
index 9178ea4f..46b8223d 100644
--- a/test/type_formatting/init.lua
+++ b/test/type_formatting/init.lua
@@ -1,16 +1,16 @@
local core = require 'core.type-formatting'
local files = require 'files'
local util = require 'utility'
+local catch = require 'catch'
rawset(_G, 'TEST', true)
function TEST(script)
return function (expect)
- local pos = script:find('$', 1, true) - 1
- local new_script = script:gsub('%$', '')
files.removeAll()
- files.setText('', new_script)
- local edits = core('', pos, expect.ch)
+ local newScript, catched = catch(script, '?')
+ files.setText('', newScript)
+ local edits = core('', catched['?'][1][1], expect.ch)
if edits then
assert(expect.edits)
assert(util.equal(edits, expect.edits))
@@ -21,80 +21,104 @@ function TEST(script)
end
TEST [[
-if true then $ end
+if true then <??> end
]]
{
ch = '\n',
edits = {
{
- start = 13,
+ start = 12,
finish = 13,
text = '\n\t',
},
{
- start = 14,
- finish = 17,
+ start = 13,
+ finish = 15,
text = '',
},
{
- start = 18,
- finish = 17,
- text = '\nend',
+ start = 15,
+ finish = 15,
+ text = '\ne',
},
}
}
TEST [[
-if true then $end
+if true then <??>end
]]
{
ch = '\n',
edits = {
{
- start = 13,
+ start = 12,
finish = 13,
text = '\n\t',
},
{
- start = 14,
- finish = 16,
+ start = 13,
+ finish = 14,
text = '',
},
{
- start = 17,
- finish = 16,
- text = '\nend',
+ start = 14,
+ finish = 14,
+ text = '\ne',
},
}
}
TEST [[
-if true then$end
+if true then<??>end
]]
{
ch = '\n',
edits = {
{
- start = 13,
+ start = 12,
finish = 12,
text = '\n\t',
},
{
- start = 13,
- finish = 15,
+ start = 12,
+ finish = 13,
text = '',
},
{
+ start = 13,
+ finish = 13,
+ text = '\ne',
+ },
+ }
+}
+
+TEST [[
+ if true then<??>end
+]]
+{
+ ch = '\n',
+ edits = {
+ {
start = 16,
- finish = 15,
- text = '\nend',
+ finish = 16,
+ text = '\n \t',
+ },
+ {
+ start = 16,
+ finish = 17,
+ text = '',
+ },
+ {
+ start = 17,
+ finish = 17,
+ text = '\n e',
},
}
}
TEST [[
if true then
- $
+ <??>
end
]]
{