-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.lua
63 lines (51 loc) · 968 Bytes
/
test.lua
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
local classes = {}
for i=1,10 do
classes[i] = @class : LuaObject
function getI()
return i
end
end
end
assert(||classes[3] new| init|.getI() == 3)
@class classes.A : classes[4]
@property a
@property(readonly) b = _b
@property(writeonly) c = _c
@property(setter=getD,getter=@"getD:") d = _d
function init()
_b = 5
return self
end
function (getD:__d)
if __d then
_d = __d
else
return _d
end
end
function getI()
return super.getI() + 2
end
function cc()
return _c
end
end
local aObj = ||classes.A new| init|
assert(aObj.getI() == 6)
aObj.a = 3
assert(aObj.a == 3)
assert(aObj.b == 5)
assert(not pcall(function() aObj.b = 8 end))
aObj.c = 1
assert(aObj.cc() == 1)
assert(not pcall(function() return aObj.c end))
aObj.d = 6
|aObj getD:7|
assert(|aObj getD:nil| == aObj.d and aObj.d == 7)
local @class LocalClass : LuaObject
function init()
return self
end
end
local localObj = ||LocalClass new| init|
assert(localObj)