summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-25 01:03:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-25 01:07:22 +0900
commit4b3e007e0778415e75ec2f0afcdc559eea43fdf8 (patch)
tree278d1a9b2c08d2544a2494110a39a32522038047 /test
parented65e2d5ae700afe8408836a8774becf5c87f76b (diff)
Assert no-kwrest case
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index aa6e9d57dc..cbcdefb23b 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -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)