diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/basic/init.lua | 89 |
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", + }, +} |