diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-08-24 21:23:09 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-08-24 21:23:09 +0800 |
commit | 6cbc089f83eec21a33c792943e323a0f50a56e0a (patch) | |
tree | 4df28def4aae951a96705c99991a3c82b2683470 /test/command | |
parent | 061c9b03686c7ae8b3dc70d491ff003258b13bf6 (diff) | |
download | lua-language-server-6cbc089f83eec21a33c792943e323a0f50a56e0a.zip |
command test
Diffstat (limited to 'test/command')
-rw-r--r-- | test/command/auto-require.lua | 36 | ||||
-rw-r--r-- | test/command/init.lua | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/test/command/auto-require.lua b/test/command/auto-require.lua new file mode 100644 index 00000000..94bb5069 --- /dev/null +++ b/test/command/auto-require.lua @@ -0,0 +1,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 diff --git a/test/command/init.lua b/test/command/init.lua new file mode 100644 index 00000000..85d7f0d8 --- /dev/null +++ b/test/command/init.lua @@ -0,0 +1 @@ +require 'command.auto-require' |