summaryrefslogtreecommitdiffhomepage
path: root/test/t/syntax.rb
diff options
context:
space:
mode:
authorYutaka HARA <[email protected]>2016-12-01 14:55:26 +0900
committerYutaka HARA <[email protected]>2016-12-01 14:55:26 +0900
commit3f83ec64a82410cdc16863f8242eaea30dec026f (patch)
tree224b8762cf95071bf080243b501a72306b179ff7 /test/t/syntax.rb
parent61ac564c99ab07f01f1af2809493103fc5216a85 (diff)
downloadmruby-3f83ec64a82410cdc16863f8242eaea30dec026f.tar.gz
mruby-3f83ec64a82410cdc16863f8242eaea30dec026f.zip
Add test for recently fixed bugs
Diffstat (limited to 'test/t/syntax.rb')
-rw-r--r--test/t/syntax.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index 3bc68484b..461f5430b 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -47,6 +47,19 @@ assert('yield', '11.3.5') do
end
end
+assert('redo in a for loop (#3275)') do
+ sum = 0
+ for i in 1..10
+ sum += i
+ i -= 1
+ if i > 0
+ redo
+ end
+ end
+
+ assert_equal 220, sum
+end
+
assert('Abbreviated variable assignment', '11.4.2.3.2') do
a ||= 1
b &&= 1
@@ -255,6 +268,13 @@ assert('multiple assignment (nosplat array rhs)') do
assert_equal 2, g
end
+assert('multiple assignment (empty array rhs #3236, #3239)') do
+ a,b,*c = []; assert_equal [nil, nil, []], [a, b, c]
+ a,b,*c = [1]; assert_equal [1, nil, []], [a, b, c]
+ a,b,*c = [nil]; assert_equal [nil,nil, []], [a, b, c]
+ a,b,*c = [[]]; assert_equal [[], nil, []], [a, b, c]
+end
+
assert('Return values of case statements') do
a = [] << case 1
when 3 then 2