diff options
author | yui-knk <spiketeika@gmail.com> | 2022-11-29 11:42:53 +0900 |
---|---|---|
committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2022-11-29 18:23:00 +0900 |
commit | 67ae3e97388bc9083cb3cc2f22ba8abc28d6fda3 (patch) | |
tree | 9622fd03995e9a91f1765c8b5fca1036a90966ab /test/ruby | |
parent | ed4b5c4f21d50609d1e895449f50462c293b2a9d (diff) | |
download | ruby-67ae3e97388bc9083cb3cc2f22ba8abc28d6fda3.tar.gz |
Add a test case for argument forwarding
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_ast.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index c3de36b4fb..667f8c0fd2 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -526,6 +526,16 @@ class TestAst < Test::Unit::TestCase assert_equal([:a], kwrest.call('**a')) end + def test_argument_forwarding + forwarding = lambda do |arg_str| + node = RubyVM::AbstractSyntaxTree.parse("def a(#{arg_str}) end") + node = node.children.last.children.last.children[1] + node ? [node.children[-4], node.children[-2].children, node.children[-1]] : [] + end + + assert_equal([:*, [:**], :&], forwarding.call('...')) + end + def test_ranges_numbered_parameter helper = Helper.new(__FILE__, src: "1.times {_1}") helper.validate_range |