Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions core/array/pack/shared/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@
end

ruby_version_is ""..."3.3" do
# https://bugs.ruby-lang.org/issues/19150
# NOTE: it's just a plan of the Ruby core team
it "warns that a directive is unknown" do
# additional directive ('a') is required for the X directive
-> { [@obj, @obj].pack("a R" + pack_format) }.should complain(/unknown pack directive 'R'/)
-> { [@obj, @obj].pack("a 0" + pack_format) }.should complain(/unknown pack directive '0'/)
-> { [@obj, @obj].pack("a :" + pack_format) }.should complain(/unknown pack directive ':'/)
-> { [@obj, @obj].pack("a R" + pack_format) }.should complain(/unknown pack directive 'R' in 'a R#{pack_format}'/)
-> { [@obj, @obj].pack("a 0" + pack_format) }.should complain(/unknown pack directive '0' in 'a 0#{pack_format}'/)
-> { [@obj, @obj].pack("a :" + pack_format) }.should complain(/unknown pack directive ':' in 'a :#{pack_format}'/)
end
end

ruby_version_is "3.3" do
# https://bugs.ruby-lang.org/issues/19150
# NOTE: Added this case just to not forget about the decision in the ticket
it "raise ArgumentError when a directive is unknown" do
# additional directive ('a') is required for the X directive
-> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/)
Expand Down
17 changes: 12 additions & 5 deletions core/string/unpack/shared/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
"abc".unpack(d).should be_an_instance_of(Array)
end

ruby_version_is ""..."3.3" do
it "warns about using an unknown directive" do
-> { "abcdefgh".unpack("a R" + unpack_format) }.should complain(/unknown unpack directive 'R' in 'a R#{unpack_format}'/)
-> { "abcdefgh".unpack("a 0" + unpack_format) }.should complain(/unknown unpack directive '0' in 'a 0#{unpack_format}'/)
-> { "abcdefgh".unpack("a :" + unpack_format) }.should complain(/unknown unpack directive ':' in 'a :#{unpack_format}'/)
end
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, /unknown unpack directive 'R'/)
-> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive '0'/)
-> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive ':'/)
it "raises ArgumentError when a directive is unknown" do
-> { "abcdefgh".unpack("a R" + unpack_format) }.should raise_error(ArgumentError, "unknown unpack directive 'R' in 'a R#{unpack_format}'")
-> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError, "unknown unpack directive '0' in 'a 0#{unpack_format}'")
-> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError, "unknown unpack directive ':' in 'a :#{unpack_format}'")
end
end
end
Expand Down