ruby-changes:58418
From: Nobuyoshi <ko1@a...>
Date: Fri, 25 Oct 2019 01:44:25 +0900 (JST)
Subject: [ruby-changes:58418] ed65e2d5ae (master): Assert no-block case
https://git.ruby-lang.org/ruby.git/commit/?id=ed65e2d5ae From ed65e2d5ae700afe8408836a8774becf5c87f76b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 25 Oct 2019 00:56:27 +0900 Subject: Assert no-block case diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 4d00f91..aa6e9d5 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1491,13 +1491,21 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1491 obj1 = Object.new def obj1.bar(*args, **kws, &block) - block.call(args, kws) + if block + block.call(args, kws) + else + [args, kws] + end end obj1.instance_eval('def foo(...) bar(...) end', __FILE__, __LINE__) klass = Class.new { def foo(*args, **kws, &block) - block.call(args, kws) + if block + block.call(args, kws) + else + [args, kws] + end end } obj2 = klass.new @@ -1505,6 +1513,7 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1513 [obj1, obj2].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) parameters = obj.:foo.parameters assert_equal(:rest, parameters.dig(0, 0)) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/