Add a test case for argument forwarding

This commit is contained in:
yui-knk 2022-11-29 11:42:53 +09:00 committed by Yuichiro Kaneko
parent ed4b5c4f21
commit 67ae3e9738
Notes: git 2022-11-29 09:23:21 +00:00

View File

@ -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