From 5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 30 Sep 2022 11:29:41 +0800 Subject: fix issue #81, refactor continue with gotos. --- spec/inputs/goto.yue | 4 ++-- spec/inputs/loops.yue | 8 ++++---- spec/inputs/test/loops_spec.yue | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'spec/inputs') diff --git a/spec/inputs/goto.yue b/spec/inputs/goto.yue index 1197251..61584ca 100644 --- a/spec/inputs/goto.yue +++ b/spec/inputs/goto.yue @@ -10,8 +10,8 @@ do for z = 1, 10 do for y = 1, 10 do for x = 1, 10 if x^2 + y^2 == z^2 print 'found a Pythagorean triple:', x, y, z - goto done - ::done:: + goto ok + ::ok:: do for z = 1, 10 diff --git a/spec/inputs/loops.yue b/spec/inputs/loops.yue index d03e661..d997c65 100644 --- a/spec/inputs/loops.yue +++ b/spec/inputs/loops.yue @@ -111,10 +111,10 @@ until a == 10 x = 0 repeat - x += 1 - y = x - continue if x < 5 - print y + x += 1 + y = x + continue if x < 5 + print y until y == 10 a = 3 diff --git a/spec/inputs/test/loops_spec.yue b/spec/inputs/test/loops_spec.yue index 817919f..a115581 100644 --- a/spec/inputs/test/loops_spec.yue +++ b/spec/inputs/test/loops_spec.yue @@ -5,8 +5,8 @@ describe "loops", -> continue if x % 2 == 1 x - assert.same output, { 2,4,6 } - + assert.same { 2,4,6 }, output + it "continue in repeat", -> output = {} a = 0 @@ -19,5 +19,5 @@ describe "loops", -> output[] = a until a == 8 - assert.same output, { 1,2,4 } + assert.same { 1,2,4 }, output -- cgit v1.2.3-55-g6feb