diff options
Diffstat (limited to 'spec/inputs/attrib.yue')
-rw-r--r-- | spec/inputs/attrib.yue | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/spec/inputs/attrib.yue b/spec/inputs/attrib.yue index 500ef0f..fbff75a 100644 --- a/spec/inputs/attrib.yue +++ b/spec/inputs/attrib.yue | |||
@@ -1,3 +1,5 @@ | |||
1 | const a, b, c, d = 1, 2, 3, 4 | ||
2 | |||
1 | do | 3 | do |
2 | close a, b = setmetatable {},__close:=> print "closed" | 4 | close a, b = setmetatable {},__close:=> print "closed" |
3 | const c, d = 123, 'abc' | 5 | const c, d = 123, 'abc' |
@@ -6,6 +8,12 @@ do | |||
6 | const c, d | 8 | const c, d |
7 | 9 | ||
8 | do | 10 | do |
11 | const a, {b, c}, {d} = f!, f1! | ||
12 | |||
13 | do | ||
14 | const a, {b, c}, {d} = f! | ||
15 | |||
16 | do | ||
9 | close v = if flag | 17 | close v = if flag |
10 | func! | 18 | func! |
11 | else | 19 | else |
@@ -22,27 +30,24 @@ do | |||
22 | close d = | 30 | close d = |
23 | :value if a ?? b | 31 | :value if a ?? b |
24 | 32 | ||
25 | macro defer = (item)-> "close _ = #{item}" | ||
26 | macro defer_f = (func)-> "close _ = setmetatable {},__close:#{func}" | ||
27 | |||
28 | do | 33 | do |
29 | $defer with io.open "file.txt" | 34 | close _ = with io.open "file.txt" |
30 | \write "Hello" | 35 | \write "Hello" |
31 | 36 | ||
32 | $defer setmetatable {},__close:=> print "second" | 37 | close _ = <close>: -> print "second" |
33 | 38 | ||
34 | $defer_f -> print "first" | 39 | close _ = <close>: -> print "first" |
35 | 40 | ||
36 | _defers = setmetatable {},__close:=> | 41 | _defers = setmetatable {}, __close: => |
37 | @[#@]! | 42 | @[#@]! |
38 | @[#@] = nil | 43 | @[#@] = nil |
39 | 44 | ||
40 | macro defer_i = (item)-> " | 45 | def = (item)-> |
41 | _defers[#_defers + 1] = #{item} | 46 | _defers[#_defers + 1] = item |
42 | close _ = _defers" | 47 | _defers |
43 | 48 | ||
44 | do | 49 | do |
45 | $defer_i -> print 3 | 50 | close _ = def -> print 3 |
46 | $defer_i -> print 2 | 51 | close _ = def -> print 2 |
47 | $defer_i -> print 1 | 52 | close _ = def -> print 1 |
48 | 53 | ||