summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/definition/arg.lua23
-rw-r--r--test/definition/bug.lua15
-rw-r--r--test/definition/function.lua24
-rw-r--r--test/definition/init.lua22
-rw-r--r--test/definition/local.lua191
-rw-r--r--test/definition/set.lua30
-rw-r--r--test/definition/table.lua6
-rw-r--r--test/implementation/arg.lua23
-rw-r--r--test/implementation/bug.lua15
-rw-r--r--test/implementation/function.lua24
-rw-r--r--test/implementation/if.lua106
-rw-r--r--test/implementation/init.lua57
-rw-r--r--test/implementation/local.lua191
-rw-r--r--test/implementation/set.lua31
-rw-r--r--test/implementation/table.lua6
-rw-r--r--test/main.lua31
16 files changed, 0 insertions, 795 deletions
diff --git a/test/definition/arg.lua b/test/definition/arg.lua
deleted file mode 100644
index 2004d666..00000000
--- a/test/definition/arg.lua
+++ /dev/null
@@ -1,23 +0,0 @@
-TEST [[
-local function xx (<!xx!>)
- <?xx?> = 1
-end
-]]
-
-TEST [[
-local function x (x, <!...!>)
- x = <?...?>
-end
-]]
-
-TEST [[
-function mt<!:!>x()
- <?self?> = 1
-end
-]]
-
-TEST [[
-function mt:x(<!self!>)
- <?self?> = 1
-end
-]]
diff --git a/test/definition/bug.lua b/test/definition/bug.lua
deleted file mode 100644
index b0e890ca..00000000
--- a/test/definition/bug.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-TEST [[
-local <!x!>
-function _(x)
-end
-function _()
- <?x?>
-end
-]]
-
-TEST [[
-function _(<!x!>)
- do return end
- <?x?> = 1
-end
-]]
diff --git a/test/definition/function.lua b/test/definition/function.lua
deleted file mode 100644
index 1ef6a463..00000000
--- a/test/definition/function.lua
+++ /dev/null
@@ -1,24 +0,0 @@
-
-TEST [[
-function <!x!> () end
-<?x?> = 1
-]]
-
-TEST [[
-local function <!x!> () end
-<?x?> = 1
-]]
-
-TEST [[
-local x
-local function <!x!> ()
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-function x()
-end
-<?x?> = 1
-]]
diff --git a/test/definition/init.lua b/test/definition/init.lua
deleted file mode 100644
index 9bd7a1d8..00000000
--- a/test/definition/init.lua
+++ /dev/null
@@ -1,22 +0,0 @@
-local matcher = require 'matcher'
-
-rawset(_G, 'TEST', true)
-
-function TEST(script)
- local start = script:find('<!', 1, true) + 2
- local finish = script:find('!>', 1, true) - 1
- local pos = script:find('<?', 1, true) + 2
- local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
-
- local suc, a, b = matcher.definition(new_script, pos)
- assert(suc)
- assert(a == start)
- assert(b == finish)
-end
-
-require 'definition.set'
-require 'definition.local'
-require 'definition.arg'
-require 'definition.function'
---require 'definition.table'
-require 'definition.bug'
diff --git a/test/definition/local.lua b/test/definition/local.lua
deleted file mode 100644
index 0737443d..00000000
--- a/test/definition/local.lua
+++ /dev/null
@@ -1,191 +0,0 @@
-TEST [[
-local <!x!>
-<?x?> = 1
-]]
-
-TEST [[
-local z, y, <!x!>
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!> = 1
-<?x?> = 1
-]]
-
-TEST [[
-local z, y, <!x!> = 1
-<?x?> = 1
-]]
-
-TEST [[
-local x
-local <!x!>
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-do
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-if <?x?> then
- local x
-end
-]]
-
-TEST [[
-local <!x!>
-if x then
- local x
-elseif <?x?> then
- local x
-end
-]]
-
-TEST [[
-local <!x!>
-if x then
- local x
-elseif x then
- local x
-else
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-if x then
- <?x?> = 1
-elseif x then
- local x
-else
- local x
-end
-]]
-
-TEST [[
-local <!x!>
-for x = 1, 10 do
-end
-<?x?> = 1
-]]
-
-TEST [[
-local x
-for <!x!> = 1, 10 do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-for x in x do
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-for x in <?x?> do
-end
-]]
-
-TEST [[
-local x
-for <!x!> in x do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local x
-for z, y, <!x!> in x do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-while <?x?> do
-end
-]]
-
-TEST [[
-local <!x!>
-while x do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-while x do
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-repeat
- <?x?> = 1
-until true
-]]
-
-TEST [[
-local <!x!>
-repeat
- local x
-until true
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-repeat
-until <?x?>
-]]
-
-TEST [[
-local x
-repeat
- local <!x!>
-until <?x?>
-]]
-
-TEST [[
-local <!x!>
-function _()
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-return function ()
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-local x = function ()
- <?x?> = 1
-end
-]]
diff --git a/test/definition/set.lua b/test/definition/set.lua
deleted file mode 100644
index 2e48e490..00000000
--- a/test/definition/set.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-TEST [[
-<!x!> = 1
-<?x?> = 1
-]]
-
-TEST [[
-do
- <!global!> = 1
-end
-<?global?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-do
- local x = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-x = 1
-do
- local <!x!> = 1
- do
- x = 2
- end
- <?x?> = 1
-end
-]]
diff --git a/test/definition/table.lua b/test/definition/table.lua
deleted file mode 100644
index 13a3b555..00000000
--- a/test/definition/table.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-TEST [[
-local t = {
- <!x!> = 1,
-}
-t.<?x?> = 1
-]]
diff --git a/test/implementation/arg.lua b/test/implementation/arg.lua
deleted file mode 100644
index 2004d666..00000000
--- a/test/implementation/arg.lua
+++ /dev/null
@@ -1,23 +0,0 @@
-TEST [[
-local function xx (<!xx!>)
- <?xx?> = 1
-end
-]]
-
-TEST [[
-local function x (x, <!...!>)
- x = <?...?>
-end
-]]
-
-TEST [[
-function mt<!:!>x()
- <?self?> = 1
-end
-]]
-
-TEST [[
-function mt:x(<!self!>)
- <?self?> = 1
-end
-]]
diff --git a/test/implementation/bug.lua b/test/implementation/bug.lua
deleted file mode 100644
index b0e890ca..00000000
--- a/test/implementation/bug.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-TEST [[
-local <!x!>
-function _(x)
-end
-function _()
- <?x?>
-end
-]]
-
-TEST [[
-function _(<!x!>)
- do return end
- <?x?> = 1
-end
-]]
diff --git a/test/implementation/function.lua b/test/implementation/function.lua
deleted file mode 100644
index 90b75da8..00000000
--- a/test/implementation/function.lua
+++ /dev/null
@@ -1,24 +0,0 @@
-
-TEST [[
-function <!x!> () end
-<?x?> = 1
-]]
-
-TEST [[
-local function <!x!> () end
-<?x?> = 1
-]]
-
-TEST [[
-local x
-local function <!x!> ()
- <?x?> = 1
-end
-]]
-
-TEST [[
-local x
-function <!x!>()
-end
-<?x?> = 1
-]]
diff --git a/test/implementation/if.lua b/test/implementation/if.lua
deleted file mode 100644
index 0da8be1a..00000000
--- a/test/implementation/if.lua
+++ /dev/null
@@ -1,106 +0,0 @@
-TEST [[
-<!x!> = 1
-if 1 then
- x = 1
-else
- <?x?> = 1
-end
-]]
-
-TEST [[
-<!x!> = 1
-if 1 then
- <!x!> = 1
-else
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-if 1 then
- <!x!> = 1
-elseif 1 then
- <!x!> = 1
-else
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-if 1 then
- <!x!> = 1
-elseif 1 then
- <!x!> = 1
- if 1 then
- <!x!> = 1
- end
-else
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-while true do
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-for _ in _ do
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-for _ = 1, 1 do
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-x3 = 1
-repeat
- <!x3!> = 1
-until <?x3?> == 1
-]]
-
-TEST [[
-<!x!> = 1
-repeat
- <!x!> = 1
-until 1
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-while 1 do
- x = 1
- <!x!> = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-<!x!> = 1
-if 1 then
- if 1 then
- x = 1
- end
-else
- if 1 then
- <?x?> = 1
- end
-end
-]]
diff --git a/test/implementation/init.lua b/test/implementation/init.lua
deleted file mode 100644
index de8d9d63..00000000
--- a/test/implementation/init.lua
+++ /dev/null
@@ -1,57 +0,0 @@
-local matcher = require 'matcher'
-
-rawset(_G, 'TEST', true)
-
-local function catch_target(script)
- local list = {}
- local cur = 1
- while true do
- local start, finish = script:find('<!.-!>', cur)
- if not start then
- break
- end
- list[#list+1] = { start + 2, finish - 2 }
- cur = finish + 1
- end
- return list
-end
-
-local function founded(targets, results)
- while true do
- local target = table.remove(targets)
- if not target then
- break
- end
- for i, result in ipairs(results) do
- if target[1] == result[1] and target[2] == result[2] then
- table.remove(results, i)
- goto CONTINUE
- end
- end
- do return false end
- ::CONTINUE::
- end
- if #results == 0 then
- return true
- else
- return false
- end
-end
-
-function TEST(script)
- local target = catch_target(script)
- local pos = script:find('<?', 1, true) + 2
- local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
-
- local suc, result = matcher.implementation(new_script, pos)
- assert(suc)
- assert(founded(target, result))
-end
-
-require 'implementation.set'
-require 'implementation.local'
-require 'implementation.arg'
-require 'implementation.function'
-require 'implementation.if'
---require 'implementation.table'
-require 'implementation.bug'
diff --git a/test/implementation/local.lua b/test/implementation/local.lua
deleted file mode 100644
index 7e9b3db0..00000000
--- a/test/implementation/local.lua
+++ /dev/null
@@ -1,191 +0,0 @@
-TEST [[
-local <!x!>
-<?x?> = 1
-]]
-
-TEST [[
-local z, y, <!x!>
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!> = 1
-<?x?> = 1
-]]
-
-TEST [[
-local z, y, <!x!> = 1
-<?x?> = 1
-]]
-
-TEST [[
-local x
-local <!x!>
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-do
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-if <?x?> then
- local x
-end
-]]
-
-TEST [[
-local <!x2!>
-if x2 then
- local x2
-elseif <?x2?> then
- local x2
-end
-]]
-
-TEST [[
-local <!x!>
-if x then
- local x
-elseif x then
- local x
-else
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-if x then
- <?x?> = 1
-elseif x then
- local x
-else
- local x
-end
-]]
-
-TEST [[
-local <!x!>
-for x = 1, 10 do
-end
-<?x?> = 1
-]]
-
-TEST [[
-local x
-for <!x!> = 1, 10 do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-for x in x do
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-for x in <?x?> do
-end
-]]
-
-TEST [[
-local x
-for <!x!> in x do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local x
-for z, y, <!x!> in x do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-while <?x?> do
-end
-]]
-
-TEST [[
-local <!x!>
-while x do
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-while x do
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-repeat
- <?x?> = 1
-until true
-]]
-
-TEST [[
-local <!x!>
-repeat
- local x
-until true
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-repeat
-until <?x?>
-]]
-
-TEST [[
-local x
-repeat
- local <!x!>
-until <?x?>
-]]
-
-TEST [[
-local <!x!>
-function _()
- local x
-end
-<?x?> = 1
-]]
-
-TEST [[
-local <!x!>
-return function ()
- <?x?> = 1
-end
-]]
-
-TEST [[
-local <!x!>
-local x = function ()
- <?x?> = 1
-end
-]]
diff --git a/test/implementation/set.lua b/test/implementation/set.lua
deleted file mode 100644
index 5c4a1a2e..00000000
--- a/test/implementation/set.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-TEST [[
-<!x!> = 1
-<?x?> = 1
-]]
-
-TEST [[
-global = 1
-do
- <!global!> = 2
-end
-<?global?> = 3
-]]
-
-TEST [[
-<!x!> = 1
-do
- local x = 1
-end
-<?x?> = 1
-]]
-
-TEST [[
-x = 1
-do
- local x = 1
- do
- <!x!> = 2
- end
- <?x?> = 1
-end
-]]
diff --git a/test/implementation/table.lua b/test/implementation/table.lua
deleted file mode 100644
index 13a3b555..00000000
--- a/test/implementation/table.lua
+++ /dev/null
@@ -1,6 +0,0 @@
-TEST [[
-local t = {
- <!x!> = 1,
-}
-t.<?x?> = 1
-]]
diff --git a/test/main.lua b/test/main.lua
deleted file mode 100644
index c33526c6..00000000
--- a/test/main.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'filesystem'
-ROOT = fs.current_path()
-package.path = (ROOT / 'src' / '?.lua'):string()
- .. ';' .. (ROOT / 'src' / '?' / 'init.lua'):string()
- .. ';' .. (ROOT / 'test' / '?.lua'):string()
- .. ';' .. (ROOT / 'test' / '?' / 'init.lua'):string()
-
-log = require 'log'
-log.init(ROOT, ROOT / 'log' / 'test.log')
-log.debug('测试开始')
-
-require 'utility'
-require 'global_protect'
-
-local function main()
- local function test(name)
- local clock = os.clock()
- print(('测试[%s]...'):format(name))
- require(name)
- print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock))
- end
-
- test 'definition'
- test 'implementation'
-
- print('测试完成')
-end
-
-main()
-
-log.debug('测试完成')