ruby-changes:60411
From: Nobuyoshi <ko1@a...>
Date: Sun, 15 Mar 2020 19:35:50 +0900 (JST)
Subject: [ruby-changes:60411] d07a6dc10e (ruby_2_7): delegate.rb: fixed keyword arguments in DelegateClass
https://git.ruby-lang.org/ruby.git/commit/?id=d07a6dc10e From d07a6dc10efa71123b36a4a3ff7d2ec6e52804d7 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] (cherry picked from commit 9bcf4f3db26249772c983896ebbc9ff41f4614db) diff --git a/lib/delegate.rb b/lib/delegate.rb index 8c176dc..6365764 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 02a3433..5660adc 100644 --- a/test/test_delegate.rb +++ b/test/test_delegate.rb @@ -330,4 +330,12 @@ class TestDelegateClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_delegate.rb#L330 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/