summaryrefslogtreecommitdiff
path: root/test/crossfile/references.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/crossfile/references.lua')
-rw-r--r--test/crossfile/references.lua222
1 files changed, 196 insertions, 26 deletions
diff --git a/test/crossfile/references.lua b/test/crossfile/references.lua
index 18e9c5f9..9e55c77a 100644
--- a/test/crossfile/references.lua
+++ b/test/crossfile/references.lua
@@ -68,7 +68,7 @@ function TEST(datas)
}
end
end
- if catched['?'] or catched['~'] then
+ if #catched['?'] > 0 or #catched['~'] > 0 then
sourceList = catched['?'] + catched['~']
sourceUri = uri
end
@@ -100,16 +100,15 @@ end
TEST {
{
- path = 'lib.lua',
+ path = 'a.lua',
content = [[
- return <!function ()
- end!>
+ ROOT = 1
]],
},
{
- path = 'a.lua',
+ path = 'b.lua',
content = [[
- local <~f~> = require 'lib'
+ print(<~ROOT~>)
]],
},
}
@@ -118,13 +117,13 @@ TEST {
{
path = 'a.lua',
content = [[
- <!ROOT!> = 1
+ <?ROOT?> = 1
]],
},
{
path = 'b.lua',
content = [[
- print(<~ROOT~>)
+ print(<!ROOT!>)
]],
},
}
@@ -133,15 +132,41 @@ TEST {
{
path = 'a.lua',
content = [[
- <~ROOT~> = 1
- ]],
+ ---@type A
+ local t
+
+ t.<!f!>()
+ ]]
},
{
path = 'b.lua',
content = [[
- print(<!ROOT!>)
- ]],
+ ---@class A
+ local mt
+
+ function mt.<?f?>()
+ end
+ ]]
+ }
+}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local t = {}
+ t.<?x?> = 1
+ return t
+ ]]
},
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+
+ print(t.<!x!>)
+ ]]
+ }
}
TEST {
@@ -149,14 +174,13 @@ TEST {
path = 'a.lua',
content = [[
local f = require 'lib'
- local <~o~> = f()
+ <!f!>()
]],
},
{
path = 'lib.lua',
content = [[
- return function ()
- return <!{}!>
+ return <?function?> ()
end
]],
},
@@ -166,20 +190,78 @@ TEST {
{
path = 'a.lua',
content = [[
- ---@type A
- local t
+ local m = {}
+ function m.<?func?>()
+ end
+ return m
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ t.<!func!>()
+ ]],
+ },
+}
- t.<!f!>()
- ]]
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ return <?function?> () end
+ ]],
},
{
path = 'b.lua',
content = [[
- ---@class A
- local mt
+ local t = require 'a'
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ ]],
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ <!t!>()
+ ]],
+ },
+}
- function mt.<~f~>()
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local function <?f?>()
end
+
+ return {
+ f = <!f!>,
+ }
+ ]]
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ local f = t.f
+
+ f()
+
+ return {
+ f = f,
+ }
]]
}
}
@@ -188,17 +270,105 @@ TEST {
{
path = 'a.lua',
content = [[
- local t = {}
- t.<~x~> = 1
- return t
+ local <?function?> f()
+ end
+
+ return {
+ f = f,
+ }
]]
},
{
path = 'b.lua',
content = [[
local t = require 'a'
+ local f = t.f
- print(t.<!x!>)
+ <!f!>()
+
+ return {
+ f = f,
+ }
]]
}
}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local <?function?> f()
+ end
+
+ return {
+ f = f,
+ }
+ ]]
+ },
+ {
+ path = 'b1.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+ {
+ path = 'b2.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+ {
+ path = 'b3.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+ {
+ path = 'b4.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+ {
+ path = 'b5.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+ {
+ path = 'b6.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+ {
+ path = 'b7.lua',
+ content = [[
+ local t = require 'a'
+ t.<!f!>()
+ ]]
+ },
+}
+
+TEST {
+ {
+ path = 'a.lua',
+ content = [[
+ local <?t?> = require 'b'
+ return <!t!>
+ ]]
+ },
+ {
+ path = 'b.lua',
+ content = [[
+ local t = require 'a'
+ return t
+ ]]
+ },
+}