summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-30 21:51:46 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2020-03-30 21:51:46 +0000
commit2655e657e1cf6eec9067a7cd9529d2f2d4cf7b5a (patch)
tree0fc0d3aa37753cc2d7965b85d61e016b0dd246c1 /test
parent77d84046c728a0a11c83e4b2a18d38e06ff1dc41 (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_5@67866 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 384c95f85b..af68346442 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)