mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
Do not turn on keyword_init for Struct subclass if keyword hash is empty
This was accidentally turned on because there was no checking for Qundef. Also, since only a single keyword is currently supported, simplify the rb_get_kwargs call.
This commit is contained in:
parent
39c3252cd1
commit
77596fb7a9
Notes:
git
2019-09-04 06:02:45 +09:00
Merged: https://github.com/ruby/ruby/pull/2423 Merged-By: jeremyevans <code@jeremyevans.net>
2 changed files with 9 additions and 7 deletions
|
@ -96,6 +96,10 @@ module TestStruct
|
|||
assert_equal([:utime, :stime, :cutime, :cstime], Process.times.members)
|
||||
end
|
||||
|
||||
def test_struct_new_with_empty_hash
|
||||
assert_equal({:a=>1}, Struct.new(:a, {}).new({:a=>1}).a)
|
||||
end
|
||||
|
||||
def test_struct_new_with_keyword_init
|
||||
@Struct.new("KeywordInitTrue", :a, :b, keyword_init: true)
|
||||
@Struct.new("KeywordInitFalse", :a, :b, keyword_init: false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue