diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-22 17:24:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-22 17:24:44 +0800 |
commit | 32aa2dac835a0c74b82b19d83d9fd06be7a947ce (patch) | |
tree | d3e162b147ebc030de703439a7dcf94bce013fe9 /test/diagnostics | |
parent | a45e980f0d51c47229d18d0f859e718d203b472f (diff) | |
download | lua-language-server-32aa2dac835a0c74b82b19d83d9fd06be7a947ce.zip |
cleanup
Diffstat (limited to 'test/diagnostics')
-rw-r--r-- | test/diagnostics/init.lua | 63 |
1 files changed, 16 insertions, 47 deletions
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index 54ac73ef..840be836 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -2,36 +2,12 @@ local core = require 'core.diagnostics' local files = require 'files' local config = require 'config' local util = require 'utility' +local catch = require 'catch' config.get 'Lua.diagnostics.neededFileStatus'['deprecated'] = 'Any' rawset(_G, 'TEST', true) -local function catch_target(script, ...) - local list = {} - local function catch(buf) - local cur = 1 - local cut = 0 - while true do - local start, finish = buf:find('<!.-!>', cur) - if not start then - break - end - list[#list+1] = { start - cut, finish - 4 - cut } - cur = finish + 1 - cut = cut + 4 - end - end - catch(script) - if ... then - for _, buf in ipairs {...} do - catch(buf) - end - end - local new_script = script:gsub('<!(.-)!>', '%1') - return new_script, list -end - local function founded(targets, results) if #targets ~= #results then return false @@ -50,8 +26,8 @@ end function TEST(script, ...) files.removeAll() - local new_script, target = catch_target(script, ...) - files.setText('', new_script) + local newScript, catched = catch(script, '!') + files.setText('', newScript) files.open('') local datas = {} core('', function (results) @@ -65,11 +41,11 @@ function TEST(script, ...) end if results[1] then - if not founded(target, results) then - error(('%s\n%s'):format(util.dump(target), util.dump(results))) + if not founded(catched['!'], results) then + error(('%s\n%s'):format(util.dump(catched['!']), util.dump(results))) end else - assert(#target == 0) + assert(catched['!'] == nil) end end @@ -99,15 +75,11 @@ local <!t!> = {} <!t!>.a = 1 ]] -TEST([[ -local <!function x() +TEST [[ +local <!function <!x!>() end!> -]], -[[ -local function <!x!>() -end ]] -) + TEST [[ local <!x!> = <!function () end!> @@ -118,21 +90,13 @@ local <!x!> <!x!> = <!function () end!> ]] -TEST([[ +TEST [[ local <!function x() end!> -local <!function y() +local <!function <!y!>() x() end!> -]], -[[ -local function x() -end -local function <!y!>() - x() -end ]] -) TEST [[ local print, _G @@ -155,6 +119,11 @@ TEST [[ ]] TEST [[ + +<! !> +]] + +TEST [[ X = 1<! !> ]] |