summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-12-20 09:15:21 -0800
committerYukihiro "Matz" Matsumoto <[email protected]>2013-12-20 09:15:21 -0800
commit83c45e73d4d52b25573c90e526e6be8c087700f6 (patch)
tree16ff487bac1c1e0f82d151527b98267392411e26
parent7dffeb6215f6274c7c60cb5fde06a3e02405532a (diff)
parente80c0c90cdb70af959ec2e7ac621f5d3386e17f8 (diff)
downloadmruby-83c45e73d4d52b25573c90e526e6be8c087700f6.tar.gz
mruby-83c45e73d4d52b25573c90e526e6be8c087700f6.zip
Merge pull request #1613 from h2so5/test-case-statements
add some tests for case statements
-rw-r--r--test/t/syntax.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index c87a81e06..4ddbefea3 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -74,3 +74,31 @@ assert('Splat and mass assignment') do
assert_equal 7, b
assert_equal [8,9], c
end
+
+assert('Return values of case statements') do
+ a = [] << case 1
+ when 3 then 2
+ when 2 then 2
+ when 1 then 2
+ end
+
+ b = [] << case 1
+ when 2 then 2
+ else
+ end
+
+ def fb
+ n = 0
+ Proc.new do
+ n += 1
+ case
+ when n % 15 == 0
+ else n
+ end
+ end
+ end
+
+ assert_equal [2], a
+ assert_equal [nil], b
+ assert_equal 1, fb.call
+end