summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-07-15 15:22:23 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-07-15 15:22:23 +0900
commitd4abbf1b77b225448a8914bbe48b400008bb40cb (patch)
treed278fed926daf9fda6062257d29e43a571ecad0b /test
parentb7d75591f36575fc0a6e56378b4fa891981d803e (diff)
downloadmruby-d4abbf1b77b225448a8914bbe48b400008bb40cb.tar.gz
mruby-d4abbf1b77b225448a8914bbe48b400008bb40cb.zip
test/syntax.rb: add tests for `break` and `redo`.
Diffstat (limited to 'test')
-rw-r--r--test/t/syntax.rb38
1 files changed, 37 insertions, 1 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index c4c99242b..515c8f361 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -48,7 +48,32 @@ assert('yield', '11.3.5') do
end
end
-assert('redo in a for loop (#3275)') do
+assert('break', '11.5.2.4.3') do
+ n = 0
+ a = []
+ while true
+ n += 1
+ a.push(n)
+ if n > 3
+ break
+ end
+ end
+
+ assert_equal [1,2,3,4], a
+
+ n = 0
+ a = []
+ 6.times do
+ n += 1
+ a.push(n)
+ if n > 3
+ break
+ end
+ end
+ assert_equal [1,2,3,4], a
+end
+
+assert('redo', '11.5.2.4.5') do
sum = 0
for i in 1..10
sum += i
@@ -59,6 +84,17 @@ assert('redo in a for loop (#3275)') do
end
assert_equal 220, sum
+
+ n = 0
+ a = []
+ 3.times do
+ n += 1
+ if n == 2
+ redo
+ end
+ a.push(n)
+ end
+ assert_equal [1,3,4], a
end
assert('Abbreviated variable assignment', '11.4.2.3.2') do