From d26a4fbfcf6babfc13ec5887b6a9995c58e6c754 Mon Sep 17 00:00:00 2001 From: The Major Date: Mon, 25 Nov 2024 00:04:17 +0000 Subject: [PATCH] Add spec for String#unpack raising ArgumentError on unknown directive --- core/string/unpack/shared/basic.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/string/unpack/shared/basic.rb b/core/string/unpack/shared/basic.rb index bb5302edc..9e26f2eaa 100644 --- a/core/string/unpack/shared/basic.rb +++ b/core/string/unpack/shared/basic.rb @@ -8,6 +8,15 @@ d.should_receive(:to_str).and_return("a"+unpack_format) "abc".unpack(d).should be_an_instance_of(Array) end + + ruby_version_is "3.3" do + # https://bugs.ruby-lang.org/issues/19150 + it 'raise ArgumentError when a directive is unknown' do + -> { "abcdefgh".unpack("a R" + unpack_format) }.should raise_error(ArgumentError) + -> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError) + -> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError) + end + end end describe :string_unpack_no_platform, shared: true do