summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-07 10:03:51 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-07 10:03:51 +0000
commit7c9bd12af58e712f08a9808246bfa5c28e5bc854 (patch)
treed1beaf90b26e6eafa6efffcb4bc8b3d0e3e568b3 /test
parent4ccfb9d123338bdf2f89d1f37025da27c312b3c3 (diff)
merge revision(s) 77596fb7a91cc119b25ac9e19b3c8682709765b4: [Backport #16138]
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_struct.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index 4748419d6b..0046e9bd04 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -92,6 +92,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)