ruby-changes:58416
From: Nobuyoshi <ko1@a...>
Date: Fri, 25 Oct 2019 01:44:25 +0900 (JST)
Subject: [ruby-changes:58416] 4b3e007e07 (master): Assert no-kwrest case
https://git.ruby-lang.org/ruby.git/commit/?id=4b3e007e07 From 4b3e007e0778415e75ec2f0afcdc559eea43fdf8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 25 Oct 2019 01:03:08 +0900 Subject: Assert no-kwrest case diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index aa6e9d5..cbcdefb 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1511,7 +1511,22 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1511 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) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/