From 32aa2dac835a0c74b82b19d83d9fd06be7a947ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 22 Sep 2021 17:24:44 +0800 Subject: cleanup --- test/diagnostics/init.lua | 63 ++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 47 deletions(-) (limited to 'test/diagnostics') 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 = {} .a = 1 ]] -TEST([[ -local () end!> -]], -[[ -local function () -end ]] -) + TEST [[ local = @@ -118,21 +90,13 @@ local = ]] -TEST([[ +TEST [[ local -local () x() end!> -]], -[[ -local function x() -end -local function () - x() -end ]] -) TEST [[ local print, _G @@ -154,6 +118,11 @@ TEST [[ ]] +TEST [[ + + +]] + TEST [[ X = 1 ]] -- cgit v1.2.3 From c951f3472628bdccdbf13a6bd95bc36cc93523fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 22 Sep 2021 17:41:25 +0800 Subject: update --- test/diagnostics/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/diagnostics') diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index 840be836..5f69bdc9 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -41,7 +41,7 @@ function TEST(script, ...) end if results[1] then - if not founded(catched['!'], results) then + if not founded(catched['!'] or {}, results) then error(('%s\n%s'):format(util.dump(catched['!']), util.dump(results))) end else -- cgit v1.2.3