blob: 94bb5069353db2e995219e3cd65dd8efa634b4b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
local util = require 'utility'
local files = require 'files'
local autoRequire = require 'core.command.autoRequire'
local client = require 'client'
local findInsertOffset = util.getUpvalue(autoRequire, 'findInsertOffset')
local applyAutoRequire = util.getUpvalue(autoRequire, 'applyAutoRequire')
local originEditText = client.editText
local EditResult
client.editText = function (uri, edits)
EditResult = edits[1]
end
function TEST(text)
return function (name)
return function (expect)
files.removeAll()
files.setText('', text)
EditResult = nil
local offset, fmt = findInsertOffset('')
applyAutoRequire('', offset, name, name, fmt)
assert(util.equal(EditResult, expect))
end
end
end
-- TODO change to position
TEST '' 'test' {
start = 0,
finish = -1,
text = '\nlocal test = require "test"\n'
}
client.editText = originEditText
|