summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorKouhei Sutou <[email protected]>2015-02-24 00:16:41 +0900
committerKouhei Sutou <[email protected]>2015-02-24 00:16:41 +0900
commit584d6de3c29cb2cfef79ff17ac12f17ace000391 (patch)
treed8397db42679b69c22f707d9dca0e611c422d227 /test
parent44d8a40bac9b900b754bc78167939a74d5efd2d0 (diff)
downloadmruby-584d6de3c29cb2cfef79ff17ac12f17ace000391.tar.gz
mruby-584d6de3c29cb2cfef79ff17ac12f17ace000391.zip
Fix a bug that if and no return value case can't return true clause value
Here is a script that reproduce this problem: x = if true 1 else case 2 when 3 end 4 end p x # => nil # 1 is expected
Diffstat (limited to 'test')
-rw-r--r--test/t/syntax.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index 7ec6272fe..2621e1b19 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -241,6 +241,20 @@ assert('Return values of case statements') do
assert_equal 1, fb.call
end
+assert('Return values of if and case statements') do
+ true_clause_value =
+ if true
+ 1
+ else
+ case 2
+ when 3
+ end
+ 4
+ end
+
+ assert_equal 1, true_clause_value
+end
+
assert('splat in case statement') do
values = [3,5,1,7,8]
testa = [1,2,7]