aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2024-10-19 00:35:11 +0800
committerLi Jin <dragon-fly@qq.com>2024-10-19 00:35:11 +0800
commit1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0 (patch)
tree8bd3fbeb396fd2fce6e5b34c3ee10f4923feca72 /spec
parent05da3cbfa3689e6c229c41156d0dd08ab554cd77 (diff)
downloadyuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.tar.gz
yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.tar.bz2
yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.zip
Fixed issue #174.
Diffstat (limited to 'spec')
-rw-r--r--spec/inputs/loops.yue17
-rw-r--r--spec/outputs/5.1/loops.lua49
-rw-r--r--spec/outputs/codes_from_doc.lua16
-rw-r--r--spec/outputs/codes_from_doc_zh.lua16
-rw-r--r--spec/outputs/loops.lua37
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
200do
201 while byte := stream::read_one!
202 -- do something with the byte
203 continue if byte == 0
204 print byte
205
206do
207 local func
208 while success, result := try func 1, 2, 3
209 catch err
210 print err
211 print result
212
213do
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
442end 442end
443do
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
466end
467do
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
481end
482do
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
491end
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
586end 586end
587print("OK") 587print("OK")
588repeat
589 local byte = stream:read_one()
590 if byte then
591 print(byte)
592 else
593 break
594 end
595until false
588local list = { 596local list = {
589 1, 597 1,
590 2, 598 2,
@@ -2583,6 +2591,14 @@ do
2583 end 2591 end
2584end 2592end
2585print("OK") 2593print("OK")
2594repeat
2595 local byte = stream:read_one()
2596 if byte then
2597 print(byte)
2598 else
2599 break
2600 end
2601until false
2586local list = { 2602local 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
586end 586end
587print("好的") 587print("好的")
588repeat
589 local byte = stream:read_one()
590 if byte then
591 print(byte)
592 else
593 break
594 end
595until false
588local list = { 596local list = {
589 1, 597 1,
590 2, 598 2,
@@ -2577,6 +2585,14 @@ do
2577 end 2585 end
2578end 2586end
2579print("好的") 2587print("好的")
2588repeat
2589 local byte = stream:read_one()
2590 if byte then
2591 print(byte)
2592 else
2593 break
2594 end
2595until false
2580local list = { 2596local 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
335end 335end
336do
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
349end
350do
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
362end
363do
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
372end