Commit 83c45e73 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #1613 from h2so5/test-case-statements

add some tests for case statements
parents 7dffeb62 e80c0c90
...@@ -74,3 +74,31 @@ assert('Splat and mass assignment') do ...@@ -74,3 +74,31 @@ assert('Splat and mass assignment') do
assert_equal 7, b assert_equal 7, b
assert_equal [8,9], c assert_equal [8,9], c
end 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment