1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/mutex_m] Fix Mutex_m#initialize when the super's initialize has kwargs

Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>

https://github.com/ruby/mutex_m/commit/84ca1fc108
This commit is contained in:
Masataka Pocke Kuwabara 2020-11-24 00:37:13 +09:00 committed by Hiroshi SHIBATA
parent da126250ba
commit 60b57866ac
2 changed files with 33 additions and 0 deletions

View file

@ -113,4 +113,5 @@ module Mutex_m
mu_initialize
super
end
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
end

View file

@ -23,4 +23,36 @@ class TestMutexM < Test::Unit::TestCase
c.signal
assert_equal "abc", t.value
end
class KeywordInitializeParent
def initialize(x:)
end
end
class KeywordInitializeChild < KeywordInitializeParent
include Mutex_m
def initialize
super(x: 1)
end
end
def test_initialize_with_keyword_arg
assert KeywordInitializeChild.new
end
class NoArgInitializeParent
def initialize
end
end
class NoArgInitializeChild < NoArgInitializeParent
include Mutex_m
def initialize
super()
end
end
def test_initialize_no_args
assert NoArgInitializeChild.new
end
end