From d1cbec9b52dd3a2556aa8add4dbef4fd99f43945 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 16 Nov 2021 13:09:25 -0800 Subject: [PATCH] Add a test for bug 18343 This already passes in master, 3.0, and 2.7, but would fail in ruby 2.6 as it segfaults instead of raising an exception. I think it's good to have a test for this to catch possible future regressions. --- test/ruby/test_pack.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index af45adb2b2..9738f82b7e 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -638,6 +638,14 @@ EXPECTED end; end + def test_bug_18343 + bug18343 = '[ruby-core:106096] [Bug #18343]' + assert_separately(%W[- #{bug18343}], <<-'end;') + bug = ARGV.shift + assert_raise(ArgumentError, bug){[0].pack('c', {})} + end; + end + def test_pack_unpack_m0 assert_equal("", [""].pack("m0")) assert_equal("AA==", ["\0"].pack("m0"))