diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/syntax.yue | 49 | ||||
| -rw-r--r-- | spec/inputs/unicode/syntax.yue | 2 | ||||
| -rw-r--r-- | spec/inputs/unicode/whitespace.yue | 10 | ||||
| -rw-r--r-- | spec/inputs/whitespace.yue | 10 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc.lua | 6 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 6 | ||||
| -rw-r--r-- | spec/outputs/syntax.lua | 74 | ||||
| -rw-r--r-- | spec/outputs/unicode/syntax.lua | 4 | ||||
| -rw-r--r-- | spec/outputs/unicode/whitespace.lua | 8 | ||||
| -rw-r--r-- | spec/outputs/whitespace.lua | 8 |
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 | |||
| 7 | func arg1, arg2, another, arg3 | 7 | func arg1, arg2, another, arg3 |
| 8 | 8 | ||
| 9 | here, we = () ->, yeah | 9 | here, we = () ->, yeah |
| 10 | the, different = () -> approach; yeah | 10 | the, different = (() -> approach), yeah |
| 11 | 11 | ||
| 12 | dad() | 12 | dad() |
| 13 | dad(lord) | 13 | dad(lord) |
| @@ -321,7 +321,7 @@ ajax url, | |||
| 321 | (error) -> | 321 | (error) -> |
| 322 | print error | 322 | print error |
| 323 | 323 | ||
| 324 | -- | 324 | -- |
| 325 | a += 3 - 5 | 325 | a += 3 - 5 |
| 326 | a *= 3 + 5 | 326 | a *= 3 + 5 |
| 327 | a *= 3 | 327 | a *= 3 |
| @@ -480,11 +480,54 @@ do | |||
| 480 | 480 | ||
| 481 | do | 481 | do |
| 482 | return res if res ~= "" | 482 | return res if res ~= "" |
| 483 | 483 | ||
| 484 | 484 | ||
| 485 | do | 485 | do |
| 486 | return res if res ~= "" | 486 | return res if res ~= "" |
| 487 | -- | 487 | -- |
| 488 | 488 | ||
| 489 | do | ||
| 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 | |||
| 489 | nil | 532 | nil |
| 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 | ||
| 99 | v1, v2, \ | 99 | v1, 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 | ||
| 115 | for 变量a, \-- 解构1 | 115 | for 变量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 | ||
| 130 | v1, v2, \ | 130 | v1, 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 | ||
| 136 | a, b, \ | 136 | a, b, \ |
| 137 | c, d, \ | 137 | c, d, \ |
| 138 | e, f = 1, \ | 138 | e, 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 | ||
| 146 | for a, \-- destruct 1 | 146 | for 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) |
| 758 | end)(fn(true)) | 758 | end)(fn(true)) |
| 759 | local a = 1 | ||
| 760 | local b = 2 | ||
| 761 | print(a + b) | ||
| 759 | Rx.Observable.fromRange(1, 8):filter(function(x) | 762 | Rx.Observable.fromRange(1, 8):filter(function(x) |
| 760 | return x % 2 == 0 | 763 | return x % 2 == 0 |
| 761 | end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) | 764 | end):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) |
| 3285 | end)(fn(true)) | 3288 | end)(fn(true)) |
| 3289 | local a = 1 | ||
| 3290 | local b = 2 | ||
| 3291 | print(a + b) | ||
| 3286 | Rx.Observable.fromRange(1, 8):filter(function(x) | 3292 | Rx.Observable.fromRange(1, 8):filter(function(x) |
| 3287 | return x % 2 == 0 | 3293 | return x % 2 == 0 |
| 3288 | end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) | 3294 | end):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) |
| 758 | end)(fn(true)) | 758 | end)(fn(true)) |
| 759 | local a = 1 | ||
| 760 | local b = 2 | ||
| 761 | print(a + b) | ||
| 759 | Rx.Observable.fromRange(1, 8):filter(function(x) | 762 | Rx.Observable.fromRange(1, 8):filter(function(x) |
| 760 | return x % 2 == 0 | 763 | return x % 2 == 0 |
| 761 | end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) | 764 | end):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) |
| 3279 | end)(fn(true)) | 3282 | end)(fn(true)) |
| 3283 | local a = 1 | ||
| 3284 | local b = 2 | ||
| 3285 | print(a + b) | ||
| 3280 | Rx.Observable.fromRange(1, 8):filter(function(x) | 3286 | Rx.Observable.fromRange(1, 8):filter(function(x) |
| 3281 | return x % 2 == 0 | 3287 | return x % 2 == 0 |
| 3282 | end):concat(Rx.Observable.of('who do we appreciate')):map(function(value) | 3288 | end):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) | |||
| 5 | local we | 5 | local we |
| 6 | here, we = function() end, yeah | 6 | here, we = function() end, yeah |
| 7 | local the, different | 7 | local the, different |
| 8 | the, different = function() | 8 | the, different = (function() |
| 9 | return approach | 9 | return approach |
| 10 | end, yeah | 10 | end), yeah |
| 11 | dad() | 11 | dad() |
| 12 | dad(lord) | 12 | dad(lord) |
| 13 | hello(one, two)(); | 13 | hello(one, two)(); |
| @@ -441,4 +441,74 @@ do | |||
| 441 | end | 441 | end |
| 442 | end)()) | 442 | end)()) |
| 443 | end | 443 | end |
| 444 | do | ||
| 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) | ||
| 513 | end | ||
| 444 | return nil | 514 | return 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) | |||
| 5 | local _u6211_u4eec | 5 | local _u6211_u4eec |
| 6 | _u8fd9_u91cc, _u6211_u4eec = function() end, _u662f_u7684 | 6 | _u8fd9_u91cc, _u6211_u4eec = function() end, _u662f_u7684 |
| 7 | local _u8fd9_u4e2a, _u4e0d_u540c | 7 | local _u8fd9_u4e2a, _u4e0d_u540c |
| 8 | _u8fd9_u4e2a, _u4e0d_u540c = function() | 8 | _u8fd9_u4e2a, _u4e0d_u540c = (function() |
| 9 | return _u65b9_u6cd5 | 9 | return _u65b9_u6cd5 |
| 10 | end, _u662f_u7684 | 10 | end), _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 |
| 83 | end | 83 | end |
| 84 | local v1, v2, v3 | 84 | local v1, v2, v3 |
| 85 | v1, v2, v3 = function() | 85 | v1, v2, v3 = (function() |
| 86 | return _u53d8_u91cfa | 86 | return _u53d8_u91cfa |
| 87 | end, _u53d8_u91cfb, _u53d8_u91cfc | 87 | end), _u53d8_u91cfb, _u53d8_u91cfc |
| 88 | local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc, _u53d8_u91cfd, _u53d8_u91cfe, _u53d8_u91cff = 1, f2({ | 88 | local _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 |
| 91 | for _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc in pairs(_u5bf9_u8c61tb) do | 91 | for _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) |
| 93 | end | 93 | end |
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 |
| 95 | end | 95 | end |
| 96 | local v1, v2, v3 | 96 | local v1, v2, v3 |
| 97 | v1, v2, v3 = function() | 97 | v1, v2, v3 = (function() |
| 98 | return a | 98 | return a |
| 99 | end, b, c | 99 | end), b, c |
| 100 | local a, b, c, d, e, f = 1, f2({ | 100 | local 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 |
| 103 | for a, b, c in pairs(tb) do | 103 | for a, b, c in pairs(tb) do |
| 104 | print(a, b, c) | 104 | print(a, b, c) |
| 105 | end | 105 | end |
