diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-20 12:09:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-20 12:09:06 +0800 |
commit | afea7d6f14e7534a71591447ccc5b1110836ed8c (patch) | |
tree | 65c06a356922fb8f25f7bd92cad5e04483b71b69 /test/implementation | |
parent | 2f75dac6aba312260abb74afce64b1527d2ecea0 (diff) | |
download | lua-language-server-afea7d6f14e7534a71591447ccc5b1110836ed8c.zip |
支持转到实现
Diffstat (limited to 'test/implementation')
-rw-r--r-- | test/implementation/arg.lua | 23 | ||||
-rw-r--r-- | test/implementation/bug.lua | 15 | ||||
-rw-r--r-- | test/implementation/function.lua | 24 | ||||
-rw-r--r-- | test/implementation/init.lua | 22 | ||||
-rw-r--r-- | test/implementation/local.lua | 191 | ||||
-rw-r--r-- | test/implementation/set.lua | 31 | ||||
-rw-r--r-- | test/implementation/table.lua | 6 |
7 files changed, 312 insertions, 0 deletions
diff --git a/test/implementation/arg.lua b/test/implementation/arg.lua new file mode 100644 index 00000000..2004d666 --- /dev/null +++ b/test/implementation/arg.lua @@ -0,0 +1,23 @@ +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 new file mode 100644 index 00000000..b0e890ca --- /dev/null +++ b/test/implementation/bug.lua @@ -0,0 +1,15 @@ +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 new file mode 100644 index 00000000..90b75da8 --- /dev/null +++ b/test/implementation/function.lua @@ -0,0 +1,24 @@ + +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/init.lua b/test/implementation/init.lua new file mode 100644 index 00000000..3033f340 --- /dev/null +++ b/test/implementation/init.lua @@ -0,0 +1,22 @@ +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.implementation(new_script, pos) + assert(suc) + assert(a == start) + assert(b == finish) +end + +require 'implementation.set' +require 'implementation.local' +require 'implementation.arg' +require 'implementation.function' +--require 'implementation.table' +require 'implementation.bug' diff --git a/test/implementation/local.lua b/test/implementation/local.lua new file mode 100644 index 00000000..0737443d --- /dev/null +++ b/test/implementation/local.lua @@ -0,0 +1,191 @@ +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/implementation/set.lua b/test/implementation/set.lua new file mode 100644 index 00000000..5c4a1a2e --- /dev/null +++ b/test/implementation/set.lua @@ -0,0 +1,31 @@ +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 new file mode 100644 index 00000000..13a3b555 --- /dev/null +++ b/test/implementation/table.lua @@ -0,0 +1,6 @@ +TEST [[ +local t = { + <!x!> = 1, +} +t.<?x?> = 1 +]] |