summaryrefslogtreecommitdiff
path: root/test-beta/definition
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-20 21:57:09 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-20 21:57:09 +0800
commit4ca61ec457822dd14966afa0752340ae8ce180a1 (patch)
treeae8adb1ad82c717868e551e699fd3cf3bb290089 /test-beta/definition
parentc63b2e404d8d2bb984afe3678a5ba2b2836380cc (diff)
downloadlua-language-server-4ca61ec457822dd14966afa0752340ae8ce180a1.zip
no longer beta
Diffstat (limited to 'test-beta/definition')
-rw-r--r--test-beta/definition/arg.lua19
-rw-r--r--test-beta/definition/bug.lua131
-rw-r--r--test-beta/definition/call.lua8
-rw-r--r--test-beta/definition/function.lua24
-rw-r--r--test-beta/definition/init.lua70
-rw-r--r--test-beta/definition/label.lua29
-rw-r--r--test-beta/definition/local.lua195
-rw-r--r--test-beta/definition/luadoc.lua140
-rw-r--r--test-beta/definition/method.lua31
-rw-r--r--test-beta/definition/set.lua40
-rw-r--r--test-beta/definition/special.lua126
-rw-r--r--test-beta/definition/table.lua159
12 files changed, 0 insertions, 972 deletions
diff --git a/test-beta/definition/arg.lua b/test-beta/definition/arg.lua
deleted file mode 100644
index 9e88b2bf..00000000
--- a/test-beta/definition/arg.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-TEST [[
-local function xx (<!xx!>)
- <?xx?>()
-end
-]]
-
-TEST [[
-local <!mt!>
-function mt:x()
- <?self?>()
-end
-mt:x()
-]]
-
-TEST [[
-function mt:x(<!self!>)
- <?self?>()
-end
-]]
diff --git a/test-beta/definition/bug.lua b/test-beta/definition/bug.lua
deleted file mode 100644
index 0550b3b9..00000000
--- a/test-beta/definition/bug.lua
+++ /dev/null
@@ -1,131 +0,0 @@
-TEST [[
-local <!x!>
-function _(x)
-end
-function _()
- <?x?>()
-end
-]]
-
-TEST [[
-function _(<!x!>)
- do return end
- <?x?>()
-end
-]]
-
-TEST [[
-local <!a!>
-function a:b()
- a:b()
- <?self?>()
-end
-]]
-
---TEST [[
---function _(...)
--- function _()
--- print(<?...?>)
--- end
---end
---]]
-
-TEST [[
-local <!a!>
-(<?a?> / b)()
-]]
-
-TEST [[
-local <!args!>
-io.load(root / <?args?>.source / 'API' / path)
-]]
-
-TEST [[
-obj[#<?obj?>+1] = {}
-]]
-
-TEST [[
-self = {
- results = {
- <!labels!> = {},
- }
-}
-self[self.results.<?labels?>] = lbl
-]]
-
-TEST [[
-self.results = {
- <!labels!> = {},
-}
-self[self.results.<?labels?>] = lbl
-]]
-
-TEST [[
-self.results.<!labels!> = {}
-self[self.results.<?labels?>] = lbl
-]]
-
-TEST [[
-local mt = {}
-function mt:<!x!>()
-end
-mt:x()
-mt:<?x?>()
-]]
-
-TEST [[
-local function func(<!a!>)
- x = {
- xx(),
- <?a?>,
- }
-end
-]]
-
-TEST [[
-local <!x!>
-local t = {
- ...,
- <?x?>,
-}
-]]
-
-TEST [[
-local a
-local <!b!>
-return f(), <?b?>
-]]
-
-TEST [[
-local a = os.clock()
-local <?<!b!>?> = os.clock()
-]]
-
-TEST [[
-local mt = {}
-
-function mt:<!add!>(a, b)
-end
-
-local function init()
- return mt
-end
-
-local t = init()
-t:<?add?>()
-]]
-
-TEST [[
-local mt = {}
-mt.__index = mt
-
-function mt:<!add!>(a, b)
-end
-
-local function init()
- return setmetatable({}, mt)
-end
-
-local t = init()
-t:<?add?>()
-]]
diff --git a/test-beta/definition/call.lua b/test-beta/definition/call.lua
deleted file mode 100644
index 42502f40..00000000
--- a/test-beta/definition/call.lua
+++ /dev/null
@@ -1,8 +0,0 @@
-TEST [[
-function f()
- local <!x!>
- return <!x!>
-end
-local <!y!> = f()
-print(<?y?>)
-]]
diff --git a/test-beta/definition/function.lua b/test-beta/definition/function.lua
deleted file mode 100644
index ce20f50b..00000000
--- a/test-beta/definition/function.lua
+++ /dev/null
@@ -1,24 +0,0 @@
-
-TEST [[
-function <!x!> () end
-<?x?>()
-]]
-
-TEST [[
-local function <!x!> () end
-<?x?>()
-]]
-
-TEST [[
-local x
-local function <!x!> ()
- <?x?>()
-end
-]]
-
-TEST [[
-local <!x!>
-function <!x!>()
-end
-<?x?>()
-]]
diff --git a/test-beta/definition/init.lua b/test-beta/definition/init.lua
deleted file mode 100644
index 6e6d0a9a..00000000
--- a/test-beta/definition/init.lua
+++ /dev/null
@@ -1,70 +0,0 @@
-local core = require 'core.definition'
-local files = require 'files'
-local vm = require 'vm'
-
-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)
- if #targets ~= #results then
- return false
- end
- for _, target in ipairs(targets) do
- for _, result in ipairs(results) do
- if target[1] == result[1] and target[2] == result[2] then
- goto NEXT
- end
- end
- do return false end
- ::NEXT::
- end
- return true
-end
-
-function TEST(script)
- files.removeAll()
- local target = catch_target(script)
- local start = script:find('<?', 1, true)
- local finish = script:find('?>', 1, true)
- local pos = (start + finish) // 2 + 1
- local new_script = script:gsub('<[!?]', ' '):gsub('[!?]>', ' ')
- files.setText('', new_script)
-
- local results = core('', pos)
- if results then
- local positions = {}
- for i, result in ipairs(results) do
- if not vm.isMetaFile(result.uri) then
- positions[i] = { result.target.start, result.target.finish }
- end
- end
- assert(founded(target, positions))
- else
- assert(#target == 0)
- end
-end
-
-require 'definition.local'
-require 'definition.set'
-require 'definition.arg'
-require 'definition.function'
-require 'definition.table'
-require 'definition.method'
-require 'definition.label'
-require 'definition.call'
-require 'definition.bug'
-require 'definition.special'
-require 'definition.luadoc'
diff --git a/test-beta/definition/label.lua b/test-beta/definition/label.lua
deleted file mode 100644
index 205915b6..00000000
--- a/test-beta/definition/label.lua
+++ /dev/null
@@ -1,29 +0,0 @@
-TEST [[
-::<!LABEL!>::
-goto <?LABEL?>
-]]
-
-TEST [[
-goto <?LABEL?>
-::<!LABEL!>::
-]]
-
-TEST [[
-::LABEL::
-function _()
- goto <?LABEL?>
-end
-]]
-
-TEST [[
-do
- goto <?LABEL?>
-end
-::<!LABEL!>::
-]]
-
-TEST [[
-::LABEL::
-goto <?LABEL?>
-::<!LABEL!>::
-]]
diff --git a/test-beta/definition/local.lua b/test-beta/definition/local.lua
deleted file mode 100644
index 4153bfa0..00000000
--- a/test-beta/definition/local.lua
+++ /dev/null
@@ -1,195 +0,0 @@
-TEST [[
-local <!x!>
-<?x?>()
-]]
-
-TEST [[
-local z, y, <!x!>
-<?x?>()
-]]
-
-TEST [[
-local <!x!> = 1
-<?x?>()
-]]
-
-TEST [[
-local z, y, <!x!> = 1
-<?x?>()
-]]
-
-TEST [[
-local x
-local <!x!>
-<?x?>()
-]]
-
-TEST [[
-local <!x!>
-do
- <?x?>()
-end
-]]
-
-TEST [[
-local <!x!>
-do
- local x
-end
-<?x?>()
-]]
-
-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?>()
-]]
-
-TEST [[
-local <!x!>
-if x then
- <?x?>()
-elseif x then
- local x
-else
- local x
-end
-]]
-
-TEST [[
-local <!x!>
-for x = 1, 10 do
-end
-<?x?>()
-]]
-
-TEST [[
-local x
-for <!x!> = 1, 10 do
- <?x?>()
-end
-]]
-
-TEST [[
-local <!x!>
-for x in x do
-end
-<?x?>()
-]]
-
-TEST [[
-local <!x!>
-for x in <?x?> do
-end
-]]
-
-TEST [[
-local x
-for <!x!> in x do
- <?x?>()
-end
-]]
-
-TEST [[
-local x
-for z, y, <!x!> in x do
- <?x?>()
-end
-]]
-
-TEST [[
-local <!x!>
-while <?x?> do
-end
-]]
-
-TEST [[
-local <!x!>
-while x do
- <?x?>()
-end
-]]
-
-TEST [[
-local <!x!>
-while x do
- local x
-end
-<?x?>()
-]]
-
-TEST [[
-local <!x!>
-repeat
- <?x?>()
-until true
-]]
-
-TEST [[
-local <!x!>
-repeat
- local x
-until true
-<?x?>()
-]]
-
-TEST [[
-local <!x!>
-repeat
-until <?x?>
-]]
-
-TEST [[
-local x
-repeat
- local <!x!>
-until <?x?>
-]]
-
-TEST [[
-local <!x!>
-function _()
- local x
-end
-<?x?>()
-]]
-
-TEST [[
-local <!x!>
-return function ()
- <?x?>()
-end
-]]
-
-TEST [[
-local <!x!>
-local x = function ()
- <?x?>()
-end
-]]
-
-TEST [[
-local <?<!x!>?>
-]]
diff --git a/test-beta/definition/luadoc.lua b/test-beta/definition/luadoc.lua
deleted file mode 100644
index 9360e27c..00000000
--- a/test-beta/definition/luadoc.lua
+++ /dev/null
@@ -1,140 +0,0 @@
-TEST [[
----@class <!A!>
----@class B : <?A?>
-]]
-
-TEST [[
----@class <!A!>
----@type B|<?A?>
-]]
-
-TEST [[
----@class Class
-local <?<!t!>?>
----@type Class
-local x
-]]
-
-TEST [[
----@class Class
-local <!t!>
----@type Class
-local <?<!x!>?>
-]]
-
-TEST [[
----@class A
-local mt = {}
-function mt:<!cast!>()
-end
-
----@type A
-local obj
-obj:<?cast?>()
-]]
-
-TEST [[
----@class A
-local <!mt!> = {}
-function mt:cast()
-end
-
----@type A
-local <!obj!>
-<?obj?>:cast()
-]]
-
-TEST [[
----@type A
-local <?<!obj!>?>
-
----@class A
-local <!mt!>
-]]
-
-TEST [[
----@type A
-local obj
-obj:<?func?>()
-
----@class A
-local mt
-function mt:<!func!>()
-end
-]]
-
-TEST [[
----@type A
-local obj
-obj:<?func?>()
-
-local mt = {}
-mt.__index = mt
-function mt:<!func!>()
-end
----@class A
-local obj = setmetatable({}, mt)
-]]
-
-TEST [[
----@alias <!B!> A
----@type <?B?>
-]]
-
-TEST [[
----@class <!Class!>
----@param a <?Class?>
-]]
-
-TEST [[
----@param f <!fun():void!>
-function t(<?<!f!>?>) end
-]]
-
-TEST [[
----@overload fun(y: boolean)
----@param x number
----@param y boolean
----@param z string
-function <!f!>(x, y, z) end
-
-print(<?f?>)
-]]
-
-TEST [[
-local function f()
- return 1
-end
-
----@class Class
-local <!mt!>
-
----@type Class
-local <?<!x!>?> = f()
-]]
-
-TEST [[
----@class Class
----@field <!name!> string
----@field id integer
-local mt = {}
-mt.<?name?>
-]]
-
-TEST [[
----@alias <!A!> string
-
----@type <?A?>
-]]
-
--- TODO
-do return end
-TEST [[
----@class loli
-local unit
-
-function unit:<!pants!>()
-end
-
----@see loli#<?pants?>
-]]
diff --git a/test-beta/definition/method.lua b/test-beta/definition/method.lua
deleted file mode 100644
index aa7aacdc..00000000
--- a/test-beta/definition/method.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-TEST [[
-function mt:<!a!>()
-end
-function mt:b()
- mt:<?a?>()
-end
-]]
-
-TEST [[
-function mt:<!m1!>()
-end
-function mt:m2()
- self:<?m1?>()
-end
-]]
-
-TEST [[
-function mt:m3()
- mt:<?m4?>()
-end
-function mt:<!m4!>()
-end
-]]
-
-TEST [[
-function mt:m3()
- self:<?m4?>()
-end
-function mt:<!m4!>()
-end
-]]
diff --git a/test-beta/definition/set.lua b/test-beta/definition/set.lua
deleted file mode 100644
index f36be078..00000000
--- a/test-beta/definition/set.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-TEST [[
-<!x!> = 1
-<?x?>()
-]]
-
-TEST [[
-do
- <!global!> = 1
-end
-<?global?>()
-]]
-
-TEST [[
-<!x!> = 1
-do
- local x = 1
-end
-<?x?>()
-]]
-
-TEST [[
-x = 1
-do
- local <!x!> = 1
- do
- <!x!> = 2
- end
- <?x?>()
-end
-]]
-
-TEST [[
-<!x!> = 1
-if y then
- <!x!> = 2
-else
- <!x!> = 3
-end
-print(<?x?>)
-]]
diff --git a/test-beta/definition/special.lua b/test-beta/definition/special.lua
deleted file mode 100644
index 4e3728e3..00000000
--- a/test-beta/definition/special.lua
+++ /dev/null
@@ -1,126 +0,0 @@
-TEST [[
-_ENV.<!x!> = 1
-print(<?x?>)
-]]
-
-TEST [[
-_G.<!x!> = 1
-print(<?x?>)
-]]
-
-TEST [[
-<!rawset(_G, 'x', 1)!>
-print(<?x?>)
-]]
-
-TEST [[
-local mt
-mt.__index = mt
-function mt:<!method1!>()
-end
-
-local obj = setmetatable({}, mt)
-obj:<?method1?>()
-]]
-
-TEST [[
-local mt
-function mt:<!method1!>()
-end
-
-local obj = setmetatable({}, { __index = mt })
-obj:<?method1?>()
-]]
-
-TEST [[
-local mt
-function mt:<!method1!>()
-end
-
-setmetatable(api, { __index = mt })
-api:<?method1?>()
-]]
-
-TEST [[
-local mt
-local api
-function mt:<!method1!>()
-end
-
-setmetatable(api, { __index = mt })
-api:<?method1?>()
-]]
-
--- TODO 不支持从方法内部找外部的赋值
---TEST [[
---local mt
---function mt:x()
--- self.<?init?>()
---end
---
---local obj, _ = setmetatable({}, { __index = mt })
---obj.<!init!> = 1
---obj:x()
---]]
-
--- TODO 不支持从方法内部找外部的赋值
---TEST [[
---local mt
---function mt:x()
--- self.<?init?>()
---end
---
---local obj = setmetatable({ <!init!> = 1 }, { __index = mt })
---obj:x()
---]]
-
--- TODO 不支持从方法内部找外部的赋值
---TEST [[
---local mt
---function mt:x()
--- self.a.<?out?>()
---end
---
---local obj = setmetatable({
--- a = {
--- <!out!> = 1,
--- }
---}, { __index = mt })
---obj:x()
---]]
-
-TEST [[
-local sm = setmetatable
-local mt
-mt.__index = mt
-function mt:<!method1!>()
-end
-
-local obj = sm({}, mt)
-obj:<?method1?>()
-]]
-
-TEST [[
-local mt = {}
-function mt:<!x!>()
-end
-
-local obj = setmetatable({}, {__index = mt})
-function obj:x()
-end
-
-mt:<?x?>()
-]]
-
--- TODO 通过代码执行顺序来判断?
-TEST [[
-local mt = {}
-function mt:<!x!>()
-end
-
-local obj = setmetatable({}, {__index = mt})
-function obj:<!x!>()
-end
-
-obj:<?x?>()
-]]
diff --git a/test-beta/definition/table.lua b/test-beta/definition/table.lua
deleted file mode 100644
index ba2d2aa3..00000000
--- a/test-beta/definition/table.lua
+++ /dev/null
@@ -1,159 +0,0 @@
-TEST [[
-local <!t!>
-a = {
- <?t?>
-}
-]]
-
-TEST [[
-local t
-t.<!x!> = 1
-t.<?x?>()
-]]
-
-TEST [[
-t.<!x!> = 1
-t.<?x?>()
-]]
-
-TEST [[
-local <!t!>
-t.x = 1
-<?t?>.x = 1
-]]
-
-TEST [[
-t.<!x!> = 1
-t.<?x?>.y = 1
-]]
-
-TEST [[
-local t
-t.<!x!> = 1
-t.<?x?>()
-]]
-
-TEST [[
-local t
-t[<!1!>] = 1
-t[<?1?>]()
-]]
-
-TEST [[
-local t
-t[<!true!>] = 1
-t[<?true?>]()
-]]
-
-TEST [[
-local t
-t[<!"method"!>] = 1
-t[<?"method"?>]()
-]]
-
-TEST [[
-local t
-t[<!"longString"!>] = 1
-t[<?[==[longString]==]?>]()
-]]
-
-TEST [[
-local t
-t.<!x!> = 1
-t[<?'x'?>]()
-]]
-
-TEST [[
-local t
-t.<!a!> = 1
-t.<?a?>.b()
-]]
-
-TEST [[
-local t
-local <!x!>
-t[<?x?>]()
-]]
-
-TEST[[
-local <!t!>
-local _ = {
- _ = <?t?>
-}
-]]
-
-TEST[[
-local <!t!>
-t {
- _ = <?t?>.x
-}
-]]
-
-TEST[[
-local t = {
- <!insert!> = 1,
-}
-t.<?insert?>()
-]]
-
-TEST[[
-local t = {
- [<!'insert'!>] = 1,
-}
-t.<?insert?>()
-]]
-
-TEST[[
-local t;t = {
- <!insert!> = 1,
-}
-t.<?insert?>()
-]]
-
-TEST[[
-local t;t = {
- <!insert!> = 1,
-}
-t.<?insert?>()
-]]
-
---TEST[[
---local t = {
--- <!insert!> = 1,
---}
---y.<?insert?>()
---]]
-
-TEST[[
-local t = {
- <!insert!> = 1,
-}
-local y = {
- insert = 1,
-}
-t.<?insert?>()
-]]
-
-TEST [[
-local function f()
- local t = {}
- t.field1 = {
- <!x!> = 1,
- y = 1,
- z = 1,
- }
- t.field2 = {
- x = 1,
- y = 1,
- z = 1,
- }
- t.field3 = {
- x = 1,
- y = 1,
- z = 1,
- }
- return t
-end
-local t = f()
-t.field1.<?x?>
-]]