path: root/test/test_pp.rb
diff options
authorJeremy Evans <>2020-01-21 16:14:10 -0800
committerJeremy Evans <>2020-01-22 10:27:02 -0800
commit28d31ead34baff1c4abc0d7d902ef4bc1d576fb2 (patch)
treece5ca7a1ccb88b4045a491448acd283830ea8721 /test/test_pp.rb
parent90f5c3c1ea34c992dc0f36593bf6141695dfdf67 (diff)
Fix pp when passed a empty ruby2_keywords-flagged hash as array element
This causes problems because the hash is passed to a block not accepting keywords. Because the hash is empty and keyword flagged, it is removed before calling the block. This doesn't cause an ArgumentError because it is a block and not a lambda. Just like any other block not passed required arguments, arguments not passed are set to nil. Issues like this are a strong reason not to have ruby2_keywords by default. Fixes [Bug #16519]
Notes: Merged:
Diffstat (limited to 'test/test_pp.rb')
1 files changed, 4 insertions, 0 deletions
diff --git a/test/test_pp.rb b/test/test_pp.rb
index 3262417..026b2ac 100644
--- a/test/test_pp.rb
+++ b/test/test_pp.rb
@@ -176,6 +176,10 @@ class PPSingleLineTest < Test::Unit::TestCase
assert_equal("{1=>1}", PP.singleline_pp({ 1 => 1}, ''.dup)) # [ruby-core:02699]
assert_equal("[1#{', 1'*99}]", PP.singleline_pp([1]*100, ''.dup))
+ def test_hash_in_array
+ assert_equal("[{}]", PP.singleline_pp([->(*a){a.last}**{})], ''.dup))
+ end
class PPDelegateTest < Test::Unit::TestCase