diff options
author | Li Jin <dragon-fly@qq.com> | 2022-09-30 11:29:41 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-09-30 11:29:41 +0800 |
commit | 5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2 (patch) | |
tree | 5c5c0ecdab0d19544652bc05b70d8131e1645337 /spec/inputs | |
parent | a6b6753fda9745f316f3236462b74794b35b85c9 (diff) | |
download | yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.gz yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.tar.bz2 yuescript-5aa41b436b3fdf29f5a0046c68cb60b16fa09eb2.zip |
fix issue #81, refactor continue with gotos.
Diffstat (limited to 'spec/inputs')
-rw-r--r-- | spec/inputs/goto.yue | 4 | ||||
-rw-r--r-- | spec/inputs/loops.yue | 8 | ||||
-rw-r--r-- | spec/inputs/test/loops_spec.yue | 6 |
3 files changed, 9 insertions, 9 deletions
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 | |||
10 | for z = 1, 10 do for y = 1, 10 do for x = 1, 10 | 10 | for z = 1, 10 do for y = 1, 10 do for x = 1, 10 |
11 | if x^2 + y^2 == z^2 | 11 | if x^2 + y^2 == z^2 |
12 | print 'found a Pythagorean triple:', x, y, z | 12 | print 'found a Pythagorean triple:', x, y, z |
13 | goto done | 13 | goto ok |
14 | ::done:: | 14 | ::ok:: |
15 | 15 | ||
16 | do | 16 | do |
17 | for z = 1, 10 | 17 | 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 | |||
111 | 111 | ||
112 | x = 0 | 112 | x = 0 |
113 | repeat | 113 | repeat |
114 | x += 1 | 114 | x += 1 |
115 | y = x | 115 | y = x |
116 | continue if x < 5 | 116 | continue if x < 5 |
117 | print y | 117 | print y |
118 | until y == 10 | 118 | until y == 10 |
119 | 119 | ||
120 | a = 3 | 120 | 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", -> | |||
5 | continue if x % 2 == 1 | 5 | continue if x % 2 == 1 |
6 | x | 6 | x |
7 | 7 | ||
8 | assert.same output, { 2,4,6 } | 8 | assert.same { 2,4,6 }, output |
9 | 9 | ||
10 | it "continue in repeat", -> | 10 | it "continue in repeat", -> |
11 | output = {} | 11 | output = {} |
12 | a = 0 | 12 | a = 0 |
@@ -19,5 +19,5 @@ describe "loops", -> | |||
19 | output[] = a | 19 | output[] = a |
20 | until a == 8 | 20 | until a == 8 |
21 | 21 | ||
22 | assert.same output, { 1,2,4 } | 22 | assert.same { 1,2,4 }, output |
23 | 23 | ||