aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/syntax.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/syntax.lua
parenta19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff)
downloadyuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz
yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2
yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip
fix test.
Diffstat (limited to 'spec/outputs/syntax.lua')
-rw-r--r--spec/outputs/syntax.lua360
1 files changed, 360 insertions, 0 deletions
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua
new file mode 100644
index 0000000..3187898
--- /dev/null
+++ b/spec/outputs/syntax.lua
@@ -0,0 +1,360 @@
1local a = 1 + 2 * 3 / 6
2local bunch, go, here
3a, bunch, go, here = another, world
4func(arg1, arg2, another, arg3)
5local we
6here, we = function() end, yeah
7local the, different
8the, different = function()
9 return approach
10end, yeah
11dad()
12dad(lord)
13hello(one, two)();
14(5 + 5)(world)
15fun(a)(b)
16fun(a)(b)
17fun(a)(b, bad(hello))
18hello(world(what(are(you(doing(here))))))
19what(the)[3243](world, yeck(heck))
20hairy[hands][are](gross)(okay(okay[world]))
21local _ = (get[something] + 5)[years]
22local i, x = 200, 300
23local yeah = (1 + 5) * 3
24yeah = ((1 + 5) * 3) / 2
25yeah = ((1 + 5) * 3) / 2 + i % 100
26local whoa = (1 + 2) * (3 + 4) * (4 + 5)
27_ = function()
28 if something then
29 return 1, 2, 4
30 end
31 return print("hello")
32end
33_ = function()
34 if hello then
35 return "heloo", "world"
36 else
37 return no, way
38 end
39end
40_ = function()
41 return 1, 2, 34
42end
43return 5 + function()
44 return 4 + 2
45end
46return 5 + (function()
47 return 4
48end) + 2
49print(5 + function()
50 _ = 34
51 return good(nads)
52end)
53something('else', "ya")
54something('else')
55something("else")
56_ = something([[hey]]) * 2
57_ = something([======[hey]======]) * 2
58_ = something[ [======[hey]======]] * 2
59_ = something('else'), 2
60_ = something("else"), 2
61_ = something([[else]]), 2
62_ = something[ [[else]]], 2
63something('else', 2)
64something("else", 2)
65something([[else]], 2)
66_ = here(we)("go")[12123]
67split("abc xyz 123"):map("#"):printAll()
68_ = f("")[a]
69_ = f(""):b()
70_ = f("").c()
71f(("")[a])
72f((""):b())
73f(("").c())
74list({
75 "abc",
76 "xyz",
77 "123"
78}):map("#"):printAll()
79_ = f({ })[a]
80_ = f({ }):b()
81_ = f({ }).c()
82local something = {
83 test = 12323,
84 what = function()
85 return print("hello world")
86 end
87}
88print(something.test)
89local frick = {
90 hello = "world"
91}
92local argon = {
93 num = 100,
94 world = function(self)
95 print(self.num)
96 return {
97 something = function()
98 return print("hi from something")
99 end
100 }
101 end,
102 somethin = function(self, str)
103 print("string is", str)
104 return {
105 world = function(a, b)
106 return print("sum", a + b)
107 end
108 }
109 end
110}
111something.what()
112argon:world().something()
113argon:somethin("200").world(1, 2)
114x = -434
115x = -hello(world(one(two)))
116local hi = -"herfef"
117x = -(function()
118 local _accum_0 = { }
119 local _len_0 = 1
120 for x in x do
121 _accum_0[_len_0] = x
122 _len_0 = _len_0 + 1
123 end
124 return _accum_0
125end)()
126if cool then
127 print("hello")
128end
129if not cool then
130 print("hello")
131end
132if not (1212 and 3434) then
133 print("hello")
134end
135for i = 1, 10 do
136 print("hello")
137end
138print("nutjob")
139if hello then
140 _ = 343
141end
142if cool then
143 print("what")
144end
145(function(...)
146 local arg = {
147 ...
148 }
149end)()
150x = function(...)
151 return dump({
152 ...
153 })
154end
155x = not true
156local y = not (5 + 5)
157y = #"hello"
158x = #{
159 #{ },
160 #{
161 1
162 },
163 #{
164 1,
165 2
166 }
167}
168_ = hello, world
169something:hello(what)(a, b)
170something:hello(what)
171something.hello:world(a, b)
172something.hello:world(1, 2, 3)(a, b)
173something.hello:world(1, 2, 3)(a, b)
174x = 1232
175x = x + (10 + 3)
176local j = j - "hello"
177y = y * 2
178y = y / 100
179local m = m % 2
180local hello = hello .. "world"
181self.__class.something = self.__class.something + 10
182self.something = self.something + 10
183local _update_0 = "hello"
184a[_update_0] = a[_update_0] + 10
185local _update_1 = "hello" .. tostring(tostring(ff))
186a[_update_1] = a[_update_1] + 10
187a[four].x = a[four].x + 10
188x = 0
189local _list_0 = values
190for _index_0 = 1, #_list_0 do
191 local v = _list_0[_index_0]
192 _ = ((function()
193 if ntype(v) == "fndef" then
194 x = x + 1
195 end
196 end)())
197end
198hello = {
199 something = world,
200 ["if"] = "hello",
201 ["else"] = 3434,
202 ["function"] = "okay",
203 good = 230203
204}
205local tb = {
206 ["do"] = b,
207 (function()
208 return {
209 b = b
210 }
211 end)()
212}
213div({
214 class = "cool"
215})
216_ = 5 + what(wack)
217what(whack + 5)
218_ = 5 - what(wack)
219what(whack - 5)
220x = hello - world - something;
221(function(something)
222 if something == nil then
223 do
224 local _with_0 = what
225 _with_0:cool(100)
226 something = _with_0
227 end
228 end
229 return print(something)
230end)()
231if something then
232 _ = 03589
233else
234 _ = 3434
235end
236if something then
237 _ = yeah
238elseif "ymmm" then
239 print("cool")
240else
241 _ = okay
242end
243x = notsomething
244y = ifsomething
245local z = x and b
246z = x(andb)
247while 10 > something({
248 something = "world"
249 }) do
250 print("yeah")
251end
252x = {
253 okay = sure
254}
255yeah({
256 okay = man,
257 sure = sir
258})
259hello("no comma", {
260 yeah = dada,
261 another = world
262})
263hello("comma", {
264 something = hello_world,
265 frick = you
266})
267another(hello, one, two, three, four, {
268 yeah = man,
269 okay = yeah,
270 fine = alright
271})
272another(hello, one, two, three, four, {
273 yeah = man,
274 okay = yeah,
275 {
276 fine = alright,
277 okay = 1
278 },
279 {
280 fine = alright,
281 okay = 2
282 }
283})
284another(hello, one, two, three, four, {
285 yeah = man,
286 okay = yeah
287})
288another(hello, one, two, three, four, {
289 yeah = man({
290 okay = yeah
291 })
292})
293ajax(url, function(data)
294 return process(data)
295end, function(error)
296 return print(error)
297end)
298a = a + (3 - 5)
299a = a * (3 + 5)
300a = a * 3
301a = a >> 3
302a = a << 3
303a = a / func("cool")
304x["then"] = "hello"
305x["while"]["true"] = "hello"
306x["while"]["true"] = "hello"
307x = x or "hello"
308x = x and "hello"
309z = a - b
310z = a(-b)
311z = a - b
312z = a - b
313local str = strA .. strB .. strC
314func(3000, "192.168.1.1")
315local f
316f = function()
317 return a, b, c, d, e, f
318end
319f = function()
320 return a, b, c, d, e, f
321end
322do
323 local _with_0 = obj
324 invoke(_with_0:func(), 123, "abc")
325end
326invokeA(invokeB(invokeC(123)))
327invokeA(invokeB(invokeC(123)))
328local v = {
329 a(-1),
330 a(-1),
331 a - 1,
332 a - 1,
333 a - 1,
334 a - 1,
335 a - 1,
336 a - 1,
337 a(~1),
338 a(~1),
339 a ~ 1,
340 a ~ 1,
341 a ~ 1,
342 a ~ 1,
343 a ~ 1,
344 a ~ 1
345}
346do
347 a = 1 + 2 * 3 / 4
348 local _1 = f1(-1 + 2 + 3)
349 local _2 = f1 - 1 + 2 + 3
350 local f2
351 f2 = function(x)
352 return print(x + 1)
353 end
354 a = f2()
355 f2(-1)
356 a = f2() - f2(1)
357 local _3, _4
358 _1, _2, _3, _4 = 1, f(2, 3, f(4, 4))
359end
360return nil