diff options
| author | h2so5 <[email protected]> | 2013-12-20 15:29:23 +0900 |
|---|---|---|
| committer | h2so5 <[email protected]> | 2013-12-20 15:29:23 +0900 |
| commit | e80c0c90cdb70af959ec2e7ac621f5d3386e17f8 (patch) | |
| tree | 16ff487bac1c1e0f82d151527b98267392411e26 /test | |
| parent | 7dffeb6215f6274c7c60cb5fde06a3e02405532a (diff) | |
| download | mruby-e80c0c90cdb70af959ec2e7ac621f5d3386e17f8.tar.gz mruby-e80c0c90cdb70af959ec2e7ac621f5d3386e17f8.zip | |
add some tests for case statements
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/syntax.rb | 28 |
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 |
