aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_struct.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-03 14:02:24 -0700
committerGitHub <noreply@github.com>2019-09-03 14:02:24 -0700
commit77596fb7a91cc119b25ac9e19b3c8682709765b4 (patch)
tree93013a6d9402c577c3f9ea01789d7a69e8e414da /test/ruby/test_struct.rb
parent39c3252cd175074581855e5f9681cc723c15ff72 (diff)
downloadruby-77596fb7a91cc119b25ac9e19b3c8682709765b4.tar.gz
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.
Diffstat (limited to 'test/ruby/test_struct.rb')
-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 502affef07..ec0a29026b 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -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)