summaryrefslogtreecommitdiff
path: root/server/test/definition/method.lua
blob: 5e90177bd53ab711c9272006ccf743bba5218442 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
]]

TEST [[
local mt
mt.__index = mt
function mt:<!method1!>()
end

local obj = setmetatable({}, mt)
obj:<?method1?>()
]]

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
local api
function mt:<!method1!>()
end

setmetatable(api, { __index = mt })
api:<?method1?>()
]]

TEST [[
local mt
function mt:x()
    self.<?init?>()
end

local obj = setmetatable({}, { __index = mt })
obj.<!init!> = 1
]]

TEST [[
local mt
function mt:x()
    self.<?init?>()
end

local obj = setmetatable({ <!init!> = 1 }, { __index = mt })
]]

TEST [[
local mt
function mt:x()
    self.a.<?out?>()
end

local obj = setmetatable({
    a = {
        <!out!> = 1,
    }
}, { __index = mt })
]]

TEST [[
local sm = setmetatable
local mt
mt.__index = mt
function mt:<!method1!>()
end

local obj = sm({}, mt)
obj:<?method1?>()
]]