aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/switch.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-10-31 17:29:45 +0800
committerLi Jin <dragon-fly@qq.com>2021-10-31 17:29:45 +0800
commitaed806476fe50899c0f01750175531ac41267b9d (patch)
treec46f212a2987a9088b03e2c0225f18cd9a5d4265 /spec/outputs/switch.lua
parent60a979e224f26117f5be82bfca757a2483cef0fd (diff)
downloadyuescript-aed806476fe50899c0f01750175531ac41267b9d.tar.gz
yuescript-aed806476fe50899c0f01750175531ac41267b9d.tar.bz2
yuescript-aed806476fe50899c0f01750175531ac41267b9d.zip
partially fix issue #69, fix a few case the generated code leaks some temp variables.
Diffstat (limited to 'spec/outputs/switch.lua')
-rw-r--r--spec/outputs/switch.lua110
1 files changed, 63 insertions, 47 deletions
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua
index 1c8839f..81f6d5a 100644
--- a/spec/outputs/switch.lua
+++ b/spec/outputs/switch.lua
@@ -1,70 +1,86 @@
1local _exp_0 = value 1do
2if "cool" == _exp_0 then 2 local _exp_0 = value
3 print("hello world") 3 if "cool" == _exp_0 then
4 print("hello world")
5 end
4end 6end
5local _exp_1 = value 7do
6if "cool" == _exp_1 then 8 local _exp_0 = value
7 print("hello world") 9 if "cool" == _exp_0 then
8else 10 print("hello world")
9 print("okay rad") 11 else
12 print("okay rad")
13 end
10end 14end
11local _exp_2 = value 15do
12if "cool" == _exp_2 then 16 local _exp_0 = value
13 print("hello world") 17 if "cool" == _exp_0 then
14elseif "yeah" == _exp_2 then 18 print("hello world")
15 local _ = [[FFFF]] + [[MMMM]] 19 elseif "yeah" == _exp_0 then
16elseif (2323 + 32434) == _exp_2 then 20 local _ = [[FFFF]] + [[MMMM]]
17 print("okay") 21 elseif (2323 + 32434) == _exp_0 then
18else 22 print("okay")
19 print("okay rad") 23 else
24 print("okay rad")
25 end
20end 26end
21local out 27local out
22local _exp_3 = value 28do
23if "cool" == _exp_3 then 29 local _exp_0 = value
24 out = print("hello world") 30 if "cool" == _exp_0 then
25else 31 out = print("hello world")
26 out = print("okay rad") 32 else
33 out = print("okay rad")
34 end
27end 35end
28local _exp_4 = value 36do
29if "cool" == _exp_4 then 37 local _exp_0 = value
30 out = xxxx 38 if "cool" == _exp_0 then
31elseif "umm" == _exp_4 then 39 out = xxxx
32 out = 34340 40 elseif "umm" == _exp_0 then
33else 41 out = 34340
34 out = error("this failed big time") 42 else
43 out = error("this failed big time")
44 end
35end 45end
36do 46do
37 local _with_0 = something 47 local _with_0 = something
38 local _exp_5 = _with_0:value() 48 do
39 if _with_0.okay == _exp_5 then 49 local _exp_0 = _with_0:value()
40 local _ = "world" 50 if _with_0.okay == _exp_0 then
41 else 51 local _ = "world"
42 local _ = "yesh" 52 else
53 local _ = "yesh"
54 end
43 end 55 end
44end 56end
45fix(this) 57fix(this)
46call_func((function() 58call_func((function()
47 local _exp_5 = something 59 local _exp_0 = something
48 if 1 == _exp_5 then 60 if 1 == _exp_0 then
49 return "yes" 61 return "yes"
50 else 62 else
51 return "no" 63 return "no"
52 end 64 end
53end)()) 65end)())
54local _exp_5 = hi 66do
55if (hello or world) == _exp_5 then 67 local _exp_0 = hi
56 local _ = greene 68 if (hello or world) == _exp_0 then
69 local _ = greene
70 end
57end 71end
58local _exp_6 = hi 72do
59if "one" == _exp_6 or "two" == _exp_6 then 73 local _exp_0 = hi
60 print("cool") 74 if "one" == _exp_0 or "two" == _exp_0 then
61elseif "dad" == _exp_6 then 75 print("cool")
62 local _ = no 76 elseif "dad" == _exp_0 then
77 local _ = no
78 end
63end 79end
64local _exp_7 = hi 80local _exp_0 = hi
65if (3 + 1) == _exp_7 or hello() == _exp_7 or (function() 81if (3 + 1) == _exp_0 or hello() == _exp_0 or (function()
66 return 4 82 return 4
67end)() == _exp_7 then 83end)() == _exp_0 then
68 return yello 84 return yello
69else 85else
70 return print("cool") 86 return print("cool")