diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-10-19 00:35:11 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-10-19 00:35:11 +0800 |
| commit | 1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0 (patch) | |
| tree | 8bd3fbeb396fd2fce6e5b34c3ee10f4923feca72 /spec | |
| parent | 05da3cbfa3689e6c229c41156d0dd08ab554cd77 (diff) | |
| download | yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.tar.gz yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.tar.bz2 yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.zip | |
Fixed issue #174.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/loops.yue | 17 | ||||
| -rw-r--r-- | spec/outputs/5.1/loops.lua | 49 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc.lua | 16 | ||||
| -rw-r--r-- | spec/outputs/codes_from_doc_zh.lua | 16 | ||||
| -rw-r--r-- | spec/outputs/loops.lua | 37 |
5 files changed, 135 insertions, 0 deletions
diff --git a/spec/inputs/loops.yue b/spec/inputs/loops.yue index 5cadbf0..c5b28b3 100644 --- a/spec/inputs/loops.yue +++ b/spec/inputs/loops.yue | |||
| @@ -196,3 +196,20 @@ do | |||
| 196 | print i | 196 | print i |
| 197 | continue | 197 | continue |
| 198 | print "abc" | 198 | print "abc" |
| 199 | |||
| 200 | do | ||
| 201 | while byte := stream::read_one! | ||
| 202 | -- do something with the byte | ||
| 203 | continue if byte == 0 | ||
| 204 | print byte | ||
| 205 | |||
| 206 | do | ||
| 207 | local func | ||
| 208 | while success, result := try func 1, 2, 3 | ||
| 209 | catch err | ||
| 210 | print err | ||
| 211 | print result | ||
| 212 | |||
| 213 | do | ||
| 214 | until x := func 'a', b do | ||
| 215 | print "false expected" | ||
diff --git a/spec/outputs/5.1/loops.lua b/spec/outputs/5.1/loops.lua index cc019e0..57b19be 100644 --- a/spec/outputs/5.1/loops.lua +++ b/spec/outputs/5.1/loops.lua | |||
| @@ -440,3 +440,52 @@ do | |||
| 440 | end | 440 | end |
| 441 | end | 441 | end |
| 442 | end | 442 | end |
| 443 | do | ||
| 444 | repeat | ||
| 445 | local _cond_0 = false | ||
| 446 | local _continue_0 = false | ||
| 447 | repeat | ||
| 448 | local byte = stream:read_one() | ||
| 449 | if byte then | ||
| 450 | if byte == 0 then | ||
| 451 | _cond_0 = false | ||
| 452 | _continue_0 = true | ||
| 453 | break | ||
| 454 | end | ||
| 455 | print(byte) | ||
| 456 | else | ||
| 457 | break | ||
| 458 | end | ||
| 459 | _cond_0 = false | ||
| 460 | _continue_0 = true | ||
| 461 | until true | ||
| 462 | if not _continue_0 then | ||
| 463 | break | ||
| 464 | end | ||
| 465 | until _cond_0 | ||
| 466 | end | ||
| 467 | do | ||
| 468 | local func | ||
| 469 | repeat | ||
| 470 | local success, result = xpcall(function() | ||
| 471 | return func(1, 2, 3) | ||
| 472 | end, function(err) | ||
| 473 | return print(err) | ||
| 474 | end) | ||
| 475 | if success then | ||
| 476 | print(result) | ||
| 477 | else | ||
| 478 | break | ||
| 479 | end | ||
| 480 | until false | ||
| 481 | end | ||
| 482 | do | ||
| 483 | repeat | ||
| 484 | x = func('a', b) | ||
| 485 | if not x then | ||
| 486 | print("false expected") | ||
| 487 | else | ||
| 488 | break | ||
| 489 | end | ||
| 490 | until false | ||
| 491 | end | ||
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index 4073056..e2bba8e 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua | |||
| @@ -585,6 +585,14 @@ do | |||
| 585 | end | 585 | end |
| 586 | end | 586 | end |
| 587 | print("OK") | 587 | print("OK") |
| 588 | repeat | ||
| 589 | local byte = stream:read_one() | ||
| 590 | if byte then | ||
| 591 | print(byte) | ||
| 592 | else | ||
| 593 | break | ||
| 594 | end | ||
| 595 | until false | ||
| 588 | local list = { | 596 | local list = { |
| 589 | 1, | 597 | 1, |
| 590 | 2, | 598 | 2, |
| @@ -2583,6 +2591,14 @@ do | |||
| 2583 | end | 2591 | end |
| 2584 | end | 2592 | end |
| 2585 | print("OK") | 2593 | print("OK") |
| 2594 | repeat | ||
| 2595 | local byte = stream:read_one() | ||
| 2596 | if byte then | ||
| 2597 | print(byte) | ||
| 2598 | else | ||
| 2599 | break | ||
| 2600 | end | ||
| 2601 | until false | ||
| 2586 | local list = { | 2602 | local list = { |
| 2587 | 1, | 2603 | 1, |
| 2588 | 2, | 2604 | 2, |
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index f251450..4839525 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua | |||
| @@ -585,6 +585,14 @@ do | |||
| 585 | end | 585 | end |
| 586 | end | 586 | end |
| 587 | print("好的") | 587 | print("好的") |
| 588 | repeat | ||
| 589 | local byte = stream:read_one() | ||
| 590 | if byte then | ||
| 591 | print(byte) | ||
| 592 | else | ||
| 593 | break | ||
| 594 | end | ||
| 595 | until false | ||
| 588 | local list = { | 596 | local list = { |
| 589 | 1, | 597 | 1, |
| 590 | 2, | 598 | 2, |
| @@ -2577,6 +2585,14 @@ do | |||
| 2577 | end | 2585 | end |
| 2578 | end | 2586 | end |
| 2579 | print("好的") | 2587 | print("好的") |
| 2588 | repeat | ||
| 2589 | local byte = stream:read_one() | ||
| 2590 | if byte then | ||
| 2591 | print(byte) | ||
| 2592 | else | ||
| 2593 | break | ||
| 2594 | end | ||
| 2595 | until false | ||
| 2580 | local list = { | 2596 | local list = { |
| 2581 | 1, | 2597 | 1, |
| 2582 | 2, | 2598 | 2, |
diff --git a/spec/outputs/loops.lua b/spec/outputs/loops.lua index 40e27b9..8624d49 100644 --- a/spec/outputs/loops.lua +++ b/spec/outputs/loops.lua | |||
| @@ -333,3 +333,40 @@ do | |||
| 333 | ::_continue_11:: | 333 | ::_continue_11:: |
| 334 | end | 334 | end |
| 335 | end | 335 | end |
| 336 | do | ||
| 337 | repeat | ||
| 338 | local byte = stream:read_one() | ||
| 339 | if byte then | ||
| 340 | if byte == 0 then | ||
| 341 | goto _continue_13 | ||
| 342 | end | ||
| 343 | print(byte) | ||
| 344 | else | ||
| 345 | break | ||
| 346 | end | ||
| 347 | ::_continue_13:: | ||
| 348 | until false | ||
| 349 | end | ||
| 350 | do | ||
| 351 | local func | ||
| 352 | repeat | ||
| 353 | local success, result = xpcall(func, function(err) | ||
| 354 | return print(err) | ||
| 355 | end, 1, 2, 3) | ||
| 356 | if success then | ||
| 357 | print(result) | ||
| 358 | else | ||
| 359 | break | ||
| 360 | end | ||
| 361 | until false | ||
| 362 | end | ||
| 363 | do | ||
| 364 | repeat | ||
| 365 | x = func('a', b) | ||
| 366 | if not x then | ||
| 367 | print("false expected") | ||
| 368 | else | ||
| 369 | break | ||
| 370 | end | ||
| 371 | until false | ||
| 372 | end | ||
