ruby-changes:59881
From: Nobuyoshi <ko1@a...>
Date: Thu, 30 Jan 2020 23:19:37 +0900 (JST)
Subject: [ruby-changes:59881] 9bcf4f3db2 (master): delegate.rb: fixed keyword arguments in DelegateClass
https://git.ruby-lang.org/ruby.git/commit/?id=9bcf4f3db2 From 9bcf4f3db26249772c983896ebbc9ff41f4614db Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 21 Jan 2020 11:47:04 +0900 Subject: delegate.rb: fixed keyword arguments in DelegateClass `Delegator.delegating_block` should delegate keyword arguments separately. [ruby-core:96949] diff --git a/lib/delegate.rb b/lib/delegate.rb index 0bbe211..b7d48ef 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -334,7 +334,7 @@ def Delegator.delegating_block(mid) # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/delegate.rb#L334 lambda do |*args, &block| target = self.__getobj__ target.__send__(mid, *args, &block) - end + end.ruby2_keywords end # diff --git a/test/test_delegate.rb b/test/test_delegate.rb index 80bf416..9c47743 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -343,4 +343,12 @@ class TestDelegateClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_delegate.rb#L343 assert_equal(1, delegate.bar) assert_raise(NoMethodError, /undefined method `foo' for/) { delegate.foo } end + + def test_keyword_argument + k = EnvUtil.labeled_class("Target") do + def test(a, k:) [a, k]; end + end + a = DelegateClass(k).new(k.new) + assert_equal([1, 0], a.test(1, k: 0)) + end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/