1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Assert no-kwrest case

This commit is contained in:
Nobuyoshi Nakada 2019-10-25 01:03:08 +09:00
parent ed65e2d5ae
commit 4b3e007e07
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -1511,7 +1511,22 @@ eom
obj2 = klass.new
obj2.instance_eval('def foo(...) super(...) end', __FILE__, __LINE__)
[obj1, obj2].each do |obj|
obj3 = Object.new
def obj3.bar(*args, &block)
if kws = Hash.try_convert(args.last)
args.pop
else
kws = {}
end
if block
block.call(args, kws)
else
[args, kws]
end
end
obj3.instance_eval('def foo(...) bar(...) end', __FILE__, __LINE__)
[obj1, obj2, obj3].each do |obj|
assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5) {|*x| x})
assert_equal([[1, 2, 3], {k1: 4, k2: 5}], obj.foo(1, 2, 3, k1: 4, k2: 5))
assert_equal(-1, obj.:foo.arity)