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
|
return describe("attrib", function()
it("should support const attribute", function()
do
local x <const> = 10
return assert.same(x, 10)
end
end)
it("should support const with multiple variables", function()
do
local a <const>, b <const>, c <const> = 1, 2, 3
assert.same(a, 1)
assert.same(b, 2)
return assert.same(c, 3)
end
end)
it("should support close attribute", function()
do
local x <close> = setmetatable({ }, {
__close = function() end
})
return assert.same("table", type(x))
end
end)
it("should work with destructuring", function()
do
local a, b
do
local _obj_0 = {
a = 1,
b = 2
}
a, b = _obj_0.a, _obj_0.b
end
assert.same(a, 1)
return assert.same(b, 2)
end
end)
it("should work in conditional", function()
do
local flag = true
local x
if flag then
x = 5
end
return assert.same(x, 5)
end
end)
it("should work with switch", function()
do
local y
do
local _exp_0 = 2
if 2 == _exp_0 then
y = 100
else
y = 0
end
end
return assert.same(y, 100)
end
end)
it("should work with table literals", function()
do
local a, b
do
local _obj_0 = {
1,
2
}
a, b = _obj_0[1], _obj_0[2]
end
assert.same(a, 1)
return assert.same(b, 2)
end
end)
return it("should support close in expressions", function()
do
local result
if true then
result = setmetatable({
value = 42,
}, {
__close = function() end
})
else
result = setmetatable({
value = 0,
}, {
__close = function() end
})
end
local _close_0 <close> = result
return assert.same(result.value, 42)
end
end)
end)
|