aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-01-19 17:11:31 +0800
committerLi Jin <dragon-fly@qq.com>2026-01-19 17:11:31 +0800
commitccfe66f87663e10603e453f02894bb82dd23c93b (patch)
tree78f90066a182978bd74218440d13bd3a4dd1d269 /spec/outputs
parent8a01e9c4ec201ad7079f6863c9236851d162b864 (diff)
downloadyuescript-ccfe66f87663e10603e453f02894bb82dd23c93b.tar.gz
yuescript-ccfe66f87663e10603e453f02894bb82dd23c93b.tar.bz2
yuescript-ccfe66f87663e10603e453f02894bb82dd23c93b.zip
Made `;` work as statements separator.
Diffstat (limited to 'spec/outputs')
-rw-r--r--spec/outputs/codes_from_doc.lua6
-rw-r--r--spec/outputs/codes_from_doc_zh.lua6
-rw-r--r--spec/outputs/syntax.lua74
-rw-r--r--spec/outputs/unicode/syntax.lua4
-rw-r--r--spec/outputs/unicode/whitespace.lua8
-rw-r--r--spec/outputs/whitespace.lua8
6 files changed, 94 insertions, 12 deletions
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index 1df7cef..3b0724a 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -756,6 +756,9 @@ end
756 local first = select(1, ...) 756 local first = select(1, ...)
757 return print(ok, count, first) 757 return print(ok, count, first)
758end)(fn(true)) 758end)(fn(true))
759local a = 1
760local b = 2
761print(a + b)
759Rx.Observable.fromRange(1, 8):filter(function(x) 762Rx.Observable.fromRange(1, 8):filter(function(x)
760 return x % 2 == 0 763 return x % 2 == 0
761end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) 764end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
@@ -3283,6 +3286,9 @@ end
3283 local first = select(1, ...) 3286 local first = select(1, ...)
3284 return print(ok, count, first) 3287 return print(ok, count, first)
3285end)(fn(true)) 3288end)(fn(true))
3289local a = 1
3290local b = 2
3291print(a + b)
3286Rx.Observable.fromRange(1, 8):filter(function(x) 3292Rx.Observable.fromRange(1, 8):filter(function(x)
3287 return x % 2 == 0 3293 return x % 2 == 0
3288end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) 3294end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index b407895..89335c9 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -756,6 +756,9 @@ end
756 local first = select(1, ...) 756 local first = select(1, ...)
757 return print(ok, count, first) 757 return print(ok, count, first)
758end)(fn(true)) 758end)(fn(true))
759local a = 1
760local b = 2
761print(a + b)
759Rx.Observable.fromRange(1, 8):filter(function(x) 762Rx.Observable.fromRange(1, 8):filter(function(x)
760 return x % 2 == 0 763 return x % 2 == 0
761end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) 764end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
@@ -3277,6 +3280,9 @@ end
3277 local first = select(1, ...) 3280 local first = select(1, ...)
3278 return print(ok, count, first) 3281 return print(ok, count, first)
3279end)(fn(true)) 3282end)(fn(true))
3283local a = 1
3284local b = 2
3285print(a + b)
3280Rx.Observable.fromRange(1, 8):filter(function(x) 3286Rx.Observable.fromRange(1, 8):filter(function(x)
3281 return x % 2 == 0 3287 return x % 2 == 0
3282end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) 3288end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua
index 2df3473..d975ef7 100644
--- a/spec/outputs/syntax.lua
+++ b/spec/outputs/syntax.lua
@@ -5,9 +5,9 @@ func(arg1, arg2, another, arg3)
5local we 5local we
6here, we = function() end, yeah 6here, we = function() end, yeah
7local the, different 7local the, different
8the, different = function() 8the, different = (function()
9 return approach 9 return approach
10end, yeah 10end), yeah
11dad() 11dad()
12dad(lord) 12dad(lord)
13hello(one, two)(); 13hello(one, two)();
@@ -441,4 +441,74 @@ do
441 end 441 end
442 end)()) 442 end)())
443end 443end
444do
445 a = 1
446 local b = 2
447 local c = a + b
448 print(a)
449 print(b)
450 print(c)
451 f = function()
452 a = 1
453 b = 2
454 return a + b
455 end
456 a = 1
457 b = 2
458 local success, result = pcall(function()
459 return func()
460 end)
461 if success then
462 print(result)
463 end
464 local value = "foo"
465 print(value)
466 value = value .. "bar"
467 print(value)
468 do
469 if ok then
470 print("ok!")
471 end
472 return 42
473 end
474 for i = 1, 3 do
475 print(i)
476 goto _continue_0
477 ::_continue_0::
478 end
479 local n = 0
480 while n < 2 do
481 print("n=", n)
482 n = n + 1
483 end
484 local obj = { }
485 obj:set(10)
486 obj:get()
487 print("done")
488 do
489 local _with_0 = tbl
490 _with_0:push(1)
491 print("push")
492 end
493 a = 5
494 if a > 3 then
495 print("big")
496 b = a * 2
497 print(b)
498 else
499 print("small")
500 b = a
501 end
502 xpcall(function()
503 x = 1
504 y = 2
505 return print(x + y)
506 end, function(err)
507 return print("error:", err)
508 end)
509 local q = 1
510 local w = 2
511 local e = 3
512 print(q, w, e)
513end
444return nil 514return nil
diff --git a/spec/outputs/unicode/syntax.lua b/spec/outputs/unicode/syntax.lua
index a13302b..f5d5d8a 100644
--- a/spec/outputs/unicode/syntax.lua
+++ b/spec/outputs/unicode/syntax.lua
@@ -5,9 +5,9 @@ _u51fd_u6570(_u53c2_u65701, _u53c2_u65702, _u53e6_u5916, _u53c2_u65703)
5local _u6211_u4eec 5local _u6211_u4eec
6_u8fd9_u91cc, _u6211_u4eec = function() end, _u662f_u7684 6_u8fd9_u91cc, _u6211_u4eec = function() end, _u662f_u7684
7local _u8fd9_u4e2a, _u4e0d_u540c 7local _u8fd9_u4e2a, _u4e0d_u540c
8_u8fd9_u4e2a, _u4e0d_u540c = function() 8_u8fd9_u4e2a, _u4e0d_u540c = (function()
9 return _u65b9_u6cd5 9 return _u65b9_u6cd5
10end, _u662f_u7684 10end), _u662f_u7684
11_u7238_u7238() 11_u7238_u7238()
12_u7238_u7238(_u4e3b) 12_u7238_u7238(_u4e3b)
13_u4f60_u597d(_u4e00, _u4e8c)(); 13_u4f60_u597d(_u4e00, _u4e8c)();
diff --git a/spec/outputs/unicode/whitespace.lua b/spec/outputs/unicode/whitespace.lua
index d026abb..7a83d9f 100644
--- a/spec/outputs/unicode/whitespace.lua
+++ b/spec/outputs/unicode/whitespace.lua
@@ -82,12 +82,12 @@ v = function()
82 return _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc 82 return _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc
83end 83end
84local v1, v2, v3 84local v1, v2, v3
85v1, v2, v3 = function() 85v1, v2, v3 = (function()
86 return _u53d8_u91cfa 86 return _u53d8_u91cfa
87end, _u53d8_u91cfb, _u53d8_u91cfc 87end), _u53d8_u91cfb, _u53d8_u91cfc
88local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc, _u53d8_u91cfd, _u53d8_u91cfe, _u53d8_u91cff = 1, f2({ 88local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc, _u53d8_u91cfd, _u53d8_u91cfe, _u53d8_u91cff = 1, (f2({
89 abc = abc 89 abc = abc
90}), 3, 4, _u51fd_u65705(abc), 6 90})), 3, 4, _u51fd_u65705(abc), 6
91for _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc in pairs(_u5bf9_u8c61tb) do 91for _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc in pairs(_u5bf9_u8c61tb) do
92 _u6253_u5370(_u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc) 92 _u6253_u5370(_u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc)
93end 93end
diff --git a/spec/outputs/whitespace.lua b/spec/outputs/whitespace.lua
index 0251968..864f085 100644
--- a/spec/outputs/whitespace.lua
+++ b/spec/outputs/whitespace.lua
@@ -94,12 +94,12 @@ v = function()
94 return a, b, c 94 return a, b, c
95end 95end
96local v1, v2, v3 96local v1, v2, v3
97v1, v2, v3 = function() 97v1, v2, v3 = (function()
98 return a 98 return a
99end, b, c 99end), b, c
100local a, b, c, d, e, f = 1, f2({ 100local a, b, c, d, e, f = 1, (f2({
101 abc = abc 101 abc = abc
102}), 3, 4, f5(abc), 6 102})), 3, 4, f5(abc), 6
103for a, b, c in pairs(tb) do 103for a, b, c in pairs(tb) do
104 print(a, b, c) 104 print(a, b, c)
105end 105end