aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/macro.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-10-12 10:04:44 +0800
committerLi Jin <dragon-fly@qq.com>2021-10-12 10:04:44 +0800
commit60a979e224f26117f5be82bfca757a2483cef0fd (patch)
tree7c6af44f6dcada1f23979b820ba830251997b161 /spec/outputs/macro.lua
parenta19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff)
downloadyuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz
yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2
yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip
fix test.
Diffstat (limited to 'spec/outputs/macro.lua')
-rw-r--r--spec/outputs/macro.lua233
1 files changed, 233 insertions, 0 deletions
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua
new file mode 100644
index 0000000..a2430a2
--- /dev/null
+++ b/spec/outputs/macro.lua
@@ -0,0 +1,233 @@
1assert(item == nil);
2local v = (item == nil)
3if f1() then
4 print("OK")
5end
6if (f1() and f2() and f3()) then
7 print("OK")
8end
9if (x == "Apple" or x == "Pig" or x == "Dog") then
10 print("exist")
11end
12local _list_0 = (function()
13 local _accum_0 = { }
14 local _len_0 = 1
15 local _list_0 = (function()
16 local _accum_1 = { }
17 local _len_1 = 1
18 local _list_0 = {
19 1,
20 2,
21 3
22 }
23 for _index_0 = 1, #_list_0 do
24 local _ = _list_0[_index_0]
25 _accum_1[_len_1] = _ * 2
26 _len_1 = _len_1 + 1
27 end
28 return _accum_1
29 end)()
30 for _index_0 = 1, #_list_0 do
31 local _ = _list_0[_index_0]
32 if _ > 4 then
33 _accum_0[_len_0] = _
34 _len_0 = _len_0 + 1
35 end
36 end
37 return _accum_0
38end)()
39for _index_0 = 1, #_list_0 do
40 local _ = _list_0[_index_0]
41 print(_)
42end
43local _list_1 = (function()
44 local _accum_0 = { }
45 local _len_0 = 1
46 local _list_1 = (function()
47 local _accum_1 = { }
48 local _len_1 = 1
49 local _list_1 = {
50 1,
51 2,
52 3
53 }
54 for _index_0 = 1, #_list_1 do
55 local _ = _list_1[_index_0]
56 _accum_1[_len_1] = _ * 2
57 _len_1 = _len_1 + 1
58 end
59 return _accum_1
60 end)()
61 for _index_0 = 1, #_list_1 do
62 local _ = _list_1[_index_0]
63 if _ > 4 then
64 _accum_0[_len_0] = _
65 _len_0 = _len_0 + 1
66 end
67 end
68 return _accum_0
69end)()
70for _index_0 = 1, #_list_1 do
71 local _ = _list_1[_index_0]
72 print(_)
73end
74local val
75do
76 local _2
77 do
78 local _accum_0 = { }
79 local _len_0 = 1
80 local _list_2 = {
81 1,
82 2,
83 3
84 }
85 for _index_0 = 1, #_list_2 do
86 local _ = _list_2[_index_0]
87 _accum_0[_len_0] = _ * 2
88 _len_0 = _len_0 + 1
89 end
90 _2 = _accum_0
91 end
92 local _3
93 do
94 local _accum_0 = { }
95 local _len_0 = 1
96 for _index_0 = 1, #_2 do
97 local _ = _2[_index_0]
98 if _ > 4 then
99 _accum_0[_len_0] = _
100 _len_0 = _len_0 + 1
101 end
102 end
103 _3 = _accum_0
104 end
105 local _4
106 if #_3 == 0 then
107 _4 = 0
108 else
109 local _1 = 0
110 for _index_0 = 1, #_3 do
111 local _2 = _3[_index_0]
112 _1 = _1 + _2
113 end
114 _4 = _1
115 end
116 val = _4
117end
118(1 + 2):call(123)
119local res = (1 + 2)
120local f
121f = function(x)
122 return function(y)
123 return function(z)
124 return print(x, y, z)
125 end
126 end
127end
128do
129 local a = 8
130 do
131 a = 1
132 a = a + 1
133 end
134 a = a + (function()
135 a = 1
136 return a + 1
137 end)()
138 print(a)
139end
140do
141 local a = 8
142 a = (function()
143 local a
144 a = 1
145 return a + 1
146 end)()
147 a = a + (function()
148 local a
149 a = 1
150 return a + 1
151 end)()
152 print(a)
153end
154local x = 0;
155local function f(a)
156 return a + 1
157end
158x = x + f(3);
159function tb:func()
160 print(123)
161end
162print(x)
163local sel
164sel = function(a, b, c)
165 if a then
166 return b
167 else
168 return c
169 end
170end
171local function sel(a, b, c)
172 if a then
173 return b
174 else
175 return c
176 end
177end
178local function dummy()
179
180end
181-- a comment here
182local _ = require('underscore')
183local a = ((((_({
184 1,
185 2,
186 3,
187 4,
188 -2,
189 3
190})):chain()):map(function(self)
191 return self * 2
192end)):filter(function(self)
193 return self > 3
194end)):value();
195((((_({
196 1,
197 2,
198 3,
199 4,
200 -2,
201 3
202})):chain()):map(function(self)
203 return self * 2
204end)):filter(function(self)
205 return self > 3
206end)):each(function(self)
207 return print(self)
208end)
209local result = ((((((origin.transform.root.gameObject:Parents()):Descendants()):SelectEnable()):SelectVisible()):TagEqual("fx")):Where(function(x)
210 return x.name:EndsWith("(Clone)")
211end)):Destroy()
212do
213 local _1
214 _1 = origin.transform.root.gameObject:Parents()
215 local _2
216 _2 = _1:Descendants()
217 local _3
218 _3 = _2:SelectEnable()
219 local _4
220 _4 = _3:SelectVisible()
221 local _5
222 _5 = _4:TagEqual("fx")
223 local _6
224 _6 = _5:Where(function(x)
225 return x.name:EndsWith("(Clone)")
226 end)
227 _6:Destroy()
228end
229origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x)
230 return x.name:EndsWith("(Clone)")
231end):Destroy()
232print('abc')
233return 123