diff options
author | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
commit | 60a979e224f26117f5be82bfca757a2483cef0fd (patch) | |
tree | 7c6af44f6dcada1f23979b820ba830251997b161 /spec/outputs/attrib.lua | |
parent | a19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff) | |
download | yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2 yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip |
fix test.
Diffstat (limited to 'spec/outputs/attrib.lua')
-rw-r--r-- | spec/outputs/attrib.lua | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/outputs/attrib.lua b/spec/outputs/attrib.lua new file mode 100644 index 0000000..d9ac3f2 --- /dev/null +++ b/spec/outputs/attrib.lua | |||
@@ -0,0 +1,63 @@ | |||
1 | do | ||
2 | local a <close>, b <close> = setmetatable({ }, { | ||
3 | __close = function(self) | ||
4 | return print("closed") | ||
5 | end | ||
6 | }) | ||
7 | local c <const>, d <const> = 123, 'abc' | ||
8 | close(a, b) | ||
9 | const(c, d) | ||
10 | end | ||
11 | do | ||
12 | local v <close> = (function() | ||
13 | if flag then | ||
14 | return func() | ||
15 | else | ||
16 | return setmetatable({ }, { | ||
17 | __close = function(self) end | ||
18 | }) | ||
19 | end | ||
20 | end)() | ||
21 | local f <close> = (function() | ||
22 | local _with_0 = io.open("file.txt") | ||
23 | _with_0:write("Hello") | ||
24 | return _with_0 | ||
25 | end)() | ||
26 | end | ||
27 | do | ||
28 | local _ <close> = (function() | ||
29 | local _with_0 = io.open("file.txt") | ||
30 | _with_0:write("Hello") | ||
31 | return _with_0 | ||
32 | end)(); | ||
33 | local _ <close> = setmetatable({ }, { | ||
34 | __close = function(self) | ||
35 | return print("second") | ||
36 | end | ||
37 | }); | ||
38 | local _ <close> = setmetatable({ }, { | ||
39 | __close = function() | ||
40 | return print("first") | ||
41 | end | ||
42 | }) | ||
43 | end | ||
44 | local _defers = setmetatable({ }, { | ||
45 | __close = function(self) | ||
46 | self[#self]() | ||
47 | self[#self] = nil | ||
48 | end | ||
49 | }) | ||
50 | do | ||
51 | _defers[#_defers + 1] = function() | ||
52 | return print(3) | ||
53 | end | ||
54 | local _ <close> = _defers; | ||
55 | _defers[#_defers + 1] = function() | ||
56 | return print(2) | ||
57 | end | ||
58 | local _ <close> = _defers; | ||
59 | _defers[#_defers + 1] = function() | ||
60 | return print(1) | ||
61 | end | ||
62 | local _ <close> = _defers | ||
63 | end | ||