diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-10-03 16:59:18 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-10-03 16:59:18 +0900 |
| commit | 882bc80dd09cd22850a8c4b24ff11d405eefe189 (patch) | |
| tree | cbdcac2e4053687acabe667e10b309aea247f766 /test | |
| parent | 3d2781311e44f40aee8c9153ea1cdb991bd633d3 (diff) | |
| download | mruby-882bc80dd09cd22850a8c4b24ff11d405eefe189.tar.gz mruby-882bc80dd09cd22850a8c4b24ff11d405eefe189.zip | |
Add tests for #4746
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/syntax.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb index afb735e7f..2740789ae 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -451,6 +451,18 @@ assert('optional block argument in the rhs default expressions') do assert_nil(Proc.new {|foo = foo| foo}.call) end +assert('local variable definition in default value and subsequent arguments') do + def m(a = b = 1, c) [a, b, c] end + assert_equal([1, 1, :c], m(:c)) + assert_equal([:a, nil, :c], m(:a, :c)) + + def m(a = b = 1, &c) [a, b, c ? true : nil] end + assert_equal([1, 1, nil], m) + assert_equal([1, 1, true], m{}) + assert_equal([:a, nil, nil], m(:a)) + assert_equal([:a, nil, true], m(:a){}) +end + assert('multiline comments work correctly') do =begin this is a comment with nothing after begin and end @@ -654,4 +666,8 @@ assert 'keyword arguments' do result = m(1, 2, e: 3, g: 4, h: 5, i: 6, &(l = ->{})) assert_equal([1, 1, [], 2, 3, 2, 4, { h: 5, i: 6 }, l], result) =end + + def m(a: b = 1, c:) [a, b, c] end + assert_equal([1, 1, :c], m(c: :c)) + assert_equal([:a, nil, :c], m(a: :a, c: :c)) end |
