aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-05-16 09:45:04 +0800
committerLi Jin <dragon-fly@qq.com>2022-05-16 09:45:27 +0800
commita9fe6a5c4c17cf7e8305c1d614939ce510fb1103 (patch)
tree404509931668656356cce49493f10e27d1cc32e6 /spec
parentc4935826eea8df7a161b2b4ba9262dce66d9d366 (diff)
downloadyuescript-a9fe6a5c4c17cf7e8305c1d614939ce510fb1103.tar.gz
yuescript-a9fe6a5c4c17cf7e8305c1d614939ce510fb1103.tar.bz2
yuescript-a9fe6a5c4c17cf7e8305c1d614939ce510fb1103.zip
fix issue #97 by line decorator.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/attrib.yue8
-rw-r--r--spec/outputs/attrib.lua39
-rw-r--r--spec/outputs/loops.lua4
3 files changed, 49 insertions, 2 deletions
diff --git a/spec/inputs/attrib.yue b/spec/inputs/attrib.yue
index 7e9a42c..500ef0f 100644
--- a/spec/inputs/attrib.yue
+++ b/spec/inputs/attrib.yue
@@ -14,6 +14,14 @@ do
14 close f = with io.open "file.txt" 14 close f = with io.open "file.txt"
15 \write "Hello" 15 \write "Hello"
16 16
17do
18 const a = 1 if true
19 close b = (if x then 1) unless false
20 const c = (switch x
21 when "abc" then 998) if true
22 close d =
23 :value if a ?? b
24
17macro defer = (item)-> "close _ = #{item}" 25macro defer = (item)-> "close _ = #{item}"
18macro defer_f = (func)-> "close _ = setmetatable {},__close:#{func}" 26macro defer_f = (func)-> "close _ = setmetatable {},__close:#{func}"
19 27
diff --git a/spec/outputs/attrib.lua b/spec/outputs/attrib.lua
index d9ac3f2..aed549d 100644
--- a/spec/outputs/attrib.lua
+++ b/spec/outputs/attrib.lua
@@ -25,6 +25,45 @@ do
25 end)() 25 end)()
26end 26end
27do 27do
28 local a <const> = (function()
29 if true then
30 return 1
31 end
32 end)()
33 local b <close> = (function()
34 if not false then
35 return ((function()
36 if x then
37 return 1
38 end
39 end)())
40 end
41 end)()
42 local c <const> = (function()
43 if true then
44 return ((function()
45 local _exp_0 = x
46 if "abc" == _exp_0 then
47 return 998
48 end
49 end)())
50 end
51 end)()
52 local d <close> = (function()
53 if (function()
54 if a ~= nil then
55 return a
56 else
57 return b
58 end
59 end)() then
60 return {
61 value = value
62 }
63 end
64 end)()
65end
66do
28 local _ <close> = (function() 67 local _ <close> = (function()
29 local _with_0 = io.open("file.txt") 68 local _with_0 = io.open("file.txt")
30 _with_0:write("Hello") 69 _with_0:write("Hello")
diff --git a/spec/outputs/loops.lua b/spec/outputs/loops.lua
index bcd559c..7f87b2d 100644
--- a/spec/outputs/loops.lua
+++ b/spec/outputs/loops.lua
@@ -187,7 +187,7 @@ for i = 1, 10 do
187end 187end
188local a = 1 188local a = 1
189repeat 189repeat
190 local _cond_0 190 local _cond_0 = false
191 local _continue_0 = false 191 local _continue_0 = false
192 repeat 192 repeat
193 a = a + 1 193 a = a + 1
@@ -208,7 +208,7 @@ repeat
208until _cond_0 208until _cond_0
209x = 0 209x = 0
210repeat 210repeat
211 local _cond_0 211 local _cond_0 = false
212 local _continue_0 = false 212 local _continue_0 = false
213 repeat 213 repeat
214 x = x + 1 214 x = x + 1