summaryrefslogtreecommitdiff
path: root/test/basic
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-11 21:05:02 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-11 21:05:02 +0800
commit228613899d6d0562c1cd639e69c796fa65c2636d (patch)
tree9476134d1d89cdb038cfa07aac3e16a6228caa92 /test/basic
parent6b7a952d6537f389a85df7928ded74ca9c81eee0 (diff)
downloadlua-language-server-228613899d6d0562c1cd639e69c796fa65c2636d.zip
stash
Diffstat (limited to 'test/basic')
-rw-r--r--test/basic/init.lua89
1 files changed, 73 insertions, 16 deletions
diff --git a/test/basic/init.lua b/test/basic/init.lua
index f809a2f3..5e55c724 100644
--- a/test/basic/init.lua
+++ b/test/basic/init.lua
@@ -1,15 +1,31 @@
local files = require 'files'
+local tm = require 'text-merger'
-local text = [[
+local function TEST(source)
+ return function (expect)
+ return function (changes)
+ files.removeAll()
+ files.setText('', source)
+ local text = tm('', changes)
+ assert(text == expect)
+ end
+ end
+end
+
+TEST [[
+
+
+function Test(self)
+
+end
+]][[
function Test(self)
end
-]]
-files.setText('', text)
-local changes = {
+asser]]{
[1] = {
range = {
["end"] = {
@@ -97,21 +113,62 @@ local changes = {
},
}
-for _, change in ipairs(changes) do
- if change.range then
- local start, finish = files.unrange('', change.range)
- text = text:sub(1, start - 1) .. change.text .. text:sub(finish)
- else
- text = change.text
- end
- files.setRawText('', text)
-end
+TEST [[
+local mt = {}
-assert(text == [[
+function mt['xxx']()
+
+
+end
+]] [[
+local mt = {}
-function Test(self)
+function mt['xxx']()
+
+end
+]] {
+ [1] = {
+ range = {
+ ["end"] = {
+ character = 4,
+ line = 5,
+ },
+ start = {
+ character = 4,
+ line = 3,
+ },
+ },
+ rangeLength = 8,
+ text = "",
+ },
+}
+TEST [[
+local mt = {}
+
+function mt['xxx']()
+
end
+]] [[
+local mt = {}
-asser]])
+function mt['xxx']()
+ p
+end
+]] {
+ [1] = {
+ range = {
+ ["end"] = {
+ character = 4,
+ line = 3,
+ },
+ start = {
+ character = 4,
+ line = 3,
+ },
+ },
+ rangeLength = 0,
+ text = "p",
+ },
+}