aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/syntax.yue49
-rw-r--r--spec/inputs/unicode/syntax.yue2
-rw-r--r--spec/inputs/unicode/whitespace.yue10
-rw-r--r--spec/inputs/whitespace.yue10
-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
10 files changed, 151 insertions, 26 deletions
diff --git a/spec/inputs/syntax.yue b/spec/inputs/syntax.yue
index eee518a..cef3e3d 100644
--- a/spec/inputs/syntax.yue
+++ b/spec/inputs/syntax.yue
@@ -7,7 +7,7 @@ a, bunch, go, here = another, world, nil, nil
7func arg1, arg2, another, arg3 7func arg1, arg2, another, arg3
8 8
9here, we = () ->, yeah 9here, we = () ->, yeah
10the, different = () -> approach; yeah 10the, different = (() -> approach), yeah
11 11
12dad() 12dad()
13dad(lord) 13dad(lord)
@@ -321,7 +321,7 @@ ajax url,
321 (error) -> 321 (error) ->
322 print error 322 print error
323 323
324-- 324--
325a += 3 - 5 325a += 3 - 5
326a *= 3 + 5 326a *= 3 + 5
327a *= 3 327a *= 3
@@ -480,11 +480,54 @@ do
480 480
481do 481do
482 return res if res ~= "" 482 return res if res ~= ""
483 483
484 484
485do 485do
486 return res if res ~= "" 486 return res if res ~= ""
487 -- 487 --
488 488
489do
490 a = 1; b = 2; c = a + b
491 print a; print b; print c
492
493 f = ->
494 a = 1; b = 2; a + b
495
496 a = 1;
497 b = 2;
498
499 success, result = try func!; print result if success
500
501 value = "foo"; print value; value = value .. "bar"; print value
502
503 do
504 if ok then print "ok!"; return 42
505
506 for i=1,3
507 print i; continue
508
509 n = 0
510 while n < 2
511 print "n=", n; n += 1
512
513 obj = {}
514 obj\set 10; obj\get!; print "done"
515
516 with tbl
517 \push 1; print "push"
518
519 a = 5
520 if a > 3
521 print "big"; b = a * 2; print b
522 else
523 print "small"; b = a
524
525 try
526 x = 1; y = 2; print x + y
527 catch err
528 print "error:", err
529
530 q = 1;; w = 2;;; e = 3; print q, w, e;
531
489nil 532nil
490 533
diff --git a/spec/inputs/unicode/syntax.yue b/spec/inputs/unicode/syntax.yue
index 01d5c87..939579b 100644
--- a/spec/inputs/unicode/syntax.yue
+++ b/spec/inputs/unicode/syntax.yue
@@ -7,7 +7,7 @@
7函数 参数1, 参数2, 另外, 参数3 7函数 参数1, 参数2, 另外, 参数3
8 8
9这里, 我们 = () ->, 是的 9这里, 我们 = () ->, 是的
10这个, 不同 = () -> 方法; 是的 10这个, 不同 = (() -> 方法), 是的
11 11
12爸爸() 12爸爸()
13爸爸(主) 13爸爸(主)
diff --git a/spec/inputs/unicode/whitespace.yue b/spec/inputs/unicode/whitespace.yue
index efe55ce..151789a 100644
--- a/spec/inputs/unicode/whitespace.yue
+++ b/spec/inputs/unicode/whitespace.yue
@@ -97,19 +97,19 @@ v = ->
97 变量c -- v3 97 变量c -- v3
98 98
99v1, v2, \ 99v1, v2, \
100 v3 = -> 100 v3 = (->
101 变量a; \-- 函数结束于v1 101 变量a), \-- 函数结束于v1
102 变量b, \-- v2 102 变量b, \-- v2
103 变量c -- v3 103 变量c -- v3
104 104
105变量a, 变量b, \ 105变量a, 变量b, \
106 变量c, 变量d, \ 106 变量c, 变量d, \
107变量e, 变量f = 1, \ 107变量e, 变量f = 1, \
108 f2 108 (f2
109 :abc; \-- 参数2 109 :abc), \-- 参数2
110 3, \ 110 3, \
111 4, \ 111 4, \
112 函数5 abc; \-- 参数5 112 函数5(abc), \-- 参数5
113 6 113 6
114 114
115for 变量a, \-- 解构1 115for 变量a, \-- 解构1
diff --git a/spec/inputs/whitespace.yue b/spec/inputs/whitespace.yue
index 2655961..e501d3d 100644
--- a/spec/inputs/whitespace.yue
+++ b/spec/inputs/whitespace.yue
@@ -128,19 +128,19 @@ v = ->
128 c -- v3 128 c -- v3
129 129
130v1, v2, \ 130v1, v2, \
131 v3 = -> 131 v3 = (->
132 a; \-- end of function for v1 132 a), \-- end of function for v1
133 b, \-- v2 133 b, \-- v2
134 c -- v3 134 c -- v3
135 135
136a, b, \ 136a, b, \
137 c, d, \ 137 c, d, \
138e, f = 1, \ 138e, f = 1, \
139 f2 139 (f2
140 :abc; \-- arg2 140 :abc), \-- arg2
141 3, \ 141 3, \
142 4, \ 142 4, \
143 f5 abc; \-- arg5 143 f5(abc), \-- arg5
144 6 144 6
145 145
146for a, \-- destruct 1 146for a, \-- destruct 1
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