diff options
author | Shugo Maeda <shugo@ruby-lang.org> | 2022-11-28 10:40:08 +0900 |
---|---|---|
committer | Shugo Maeda <shugo.maeda@gmail.com> | 2022-11-29 11:22:09 +0900 |
commit | 4fc668a4f3b9b67cc7566096ab55cab34c67c158 (patch) | |
tree | b4fc3295087b50c46345f6c5ca3d754b2c4d3fe8 /test/ruby | |
parent | ee49fe5d34c1498a532bbaeaf4c12b162d0df78f (diff) | |
download | ruby-4fc668a4f3b9b67cc7566096ab55cab34c67c158.tar.gz |
Allow ** in def foo(...)
[Feature #19134]
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_syntax.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 251448ec01..a5106e0353 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -171,6 +171,23 @@ class TestSyntax < Test::Unit::TestCase end; end + def test_argument_forwarding_with_anon_rest_kwrest_and_block + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + begin; + def args(*args); args end + def kw(**kw); kw end + def block(&block); block end + def deconstruct(...); [args(*), kw(**), block(&)&.call] end + assert_equal([[], {}, nil], deconstruct) + assert_equal([[1], {}, nil], deconstruct(1)) + assert_equal([[1, 2], {}, nil], deconstruct(1, 2)) + assert_equal([[], {x: 1}, nil], deconstruct(x: 1)) + assert_equal([[], {x: 1, y: 2}, nil], deconstruct(x: 1, y: 2)) + assert_equal([[], {}, "x"], deconstruct { "x" }) + assert_equal([[1, 2], {x: 3, y: 4}, "x"], deconstruct(1, 2, x: 3, y: 4) { "x" }) + end; + end + def test_newline_in_block_parameters bug = '[ruby-dev:45292]' ["", "a", "a, b"].product(["", ";x", [";", "x"]]) do |params| |