diff options
| author | nagachika <nagachika@ruby-lang.org> | 2023-06-24 16:59:30 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-06-24 16:59:30 +0900 |
| commit | 9fca561980c6d024229d72600180b20f3f77536f (patch) | |
| tree | ce07a2046854dd93d669f91243569c38a5671dbd /spec/ruby/core/array/pack/shared | |
| parent | f89101fa3610a7b977801d60b85bcc1ea2f6dee4 (diff) | |
merge revision(s) cd5e6cc0ea48353c88d921b885b552dc76da255c,bbf54ec334fe2edd7669a944d88d17efde49a412: [Backport #19307]
Update to ruby/mspec@fef9b81
---
spec/mspec/tool/tag_from_output.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Update to ruby/spec@9d69b95
---
spec/ruby/core/array/keep_if_spec.rb | 1 +
spec/ruby/core/array/pack/c_spec.rb | 14 +-
spec/ruby/core/array/pack/shared/basic.rb | 40 ++++
spec/ruby/core/array/pack/shared/float.rb | 66 ++++++-
spec/ruby/core/array/pack/shared/integer.rb | 96 +++++++--
spec/ruby/core/array/pack/shared/numeric_basic.rb | 10 +-
spec/ruby/core/array/pack/shared/unicode.rb | 14 +-
spec/ruby/core/array/pack/w_spec.rb | 14 +-
spec/ruby/core/array/shared/unshift.rb | 18 ++
spec/ruby/core/array/values_at_spec.rb | 1 +
spec/ruby/core/array/zip_spec.rb | 6 +
spec/ruby/core/class/subclasses_spec.rb | 22 +++
spec/ruby/core/dir/home_spec.rb | 44 +++--
spec/ruby/core/dir/mkdir_spec.rb | 18 +-
spec/ruby/core/enumerable/zip_spec.rb | 5 +
spec/ruby/core/float/comparison_spec.rb | 35 ++--
spec/ruby/core/float/divmod_spec.rb | 2 +-
spec/ruby/core/float/gt_spec.rb | 21 ++
spec/ruby/core/float/gte_spec.rb | 21 ++
spec/ruby/core/float/lt_spec.rb | 21 ++
spec/ruby/core/float/lte_spec.rb | 21 ++
spec/ruby/core/float/shared/equal.rb | 21 ++
spec/ruby/core/io/gets_spec.rb | 4 +
spec/ruby/core/io/lineno_spec.rb | 9 +-
spec/ruby/core/io/new_spec.rb | 2 +
spec/ruby/core/io/readline_spec.rb | 4 +
spec/ruby/core/io/readlines_spec.rb | 4 +
spec/ruby/core/io/shared/each.rb | 4 +
spec/ruby/core/io/shared/new.rb | 2 +
spec/ruby/core/io/shared/pos.rb | 8 +-
spec/ruby/core/io/shared/readlines.rb | 4 +
spec/ruby/core/io/sysseek_spec.rb | 2 +-
spec/ruby/core/kernel/shared/load.rb | 31 ++-
spec/ruby/core/kernel/singleton_class_spec.rb | 2 +
spec/ruby/core/marshal/dump_spec.rb | 45 ++++-
spec/ruby/core/marshal/fixtures/classes.rb | 4 +
spec/ruby/core/matchdata/values_at_spec.rb | 73 ++++++-
spec/ruby/core/module/fixtures/classes.rb | 1 +
spec/ruby/core/module/include_spec.rb | 4 +-
spec/ruby/core/module/prepend_spec.rb | 12 ++
.../ruby/core/objectspace/define_finalizer_spec.rb | 22 +++
spec/ruby/core/process/constants_spec.rb | 1 +
spec/ruby/core/process/detach_spec.rb | 29 +++
spec/ruby/core/process/spawn_spec.rb | 10 +
spec/ruby/core/process/times_spec.rb | 2 +-
spec/ruby/core/queue/initialize_spec.rb | 13 +-
spec/ruby/core/refinement/import_methods_spec.rb | 34 ++++
spec/ruby/core/refinement/include_spec.rb | 27 +++
spec/ruby/core/refinement/prepend_spec.rb | 27 +++
spec/ruby/core/regexp/initialize_spec.rb | 2 +-
spec/ruby/core/signal/trap_spec.rb | 12 ++
spec/ruby/core/string/byteslice_spec.rb | 6 +
spec/ruby/core/string/capitalize_spec.rb | 4 +
spec/ruby/core/string/chars_spec.rb | 7 +-
spec/ruby/core/string/chomp_spec.rb | 4 +
spec/ruby/core/string/chop_spec.rb | 4 +
spec/ruby/core/string/clone_spec.rb | 4 +
spec/ruby/core/string/delete_prefix_spec.rb | 4 +
spec/ruby/core/string/delete_spec.rb | 4 +
spec/ruby/core/string/delete_suffix_spec.rb | 4 +
spec/ruby/core/string/downcase_spec.rb | 4 +
spec/ruby/core/string/dump_spec.rb | 10 +-
spec/ruby/core/string/dup_spec.rb | 4 +
spec/ruby/core/string/lines_spec.rb | 1 -
spec/ruby/core/string/reverse_spec.rb | 4 +
spec/ruby/core/string/scan_spec.rb | 6 +
spec/ruby/core/string/scrub_spec.rb | 10 +
spec/ruby/core/string/shared/each_line.rb | 6 +
spec/ruby/core/string/shared/partition.rb | 15 ++
spec/ruby/core/string/shared/slice.rb | 13 +-
spec/ruby/core/string/shared/strip.rb | 4 +
spec/ruby/core/string/shared/succ.rb | 4 +
spec/ruby/core/string/split_spec.rb | 17 +-
spec/ruby/core/string/squeeze_spec.rb | 5 +
spec/ruby/core/string/swapcase_spec.rb | 4 +
spec/ruby/core/string/undump_spec.rb | 2 +-
spec/ruby/core/string/unpack/b_spec.rb | 28 ++-
spec/ruby/core/string/unpack/c_spec.rb | 14 +-
spec/ruby/core/string/unpack/h_spec.rb | 28 ++-
spec/ruby/core/string/unpack/shared/basic.rb | 28 ---
spec/ruby/core/string/unpack/shared/float.rb | 60 +++++-
spec/ruby/core/string/unpack/shared/integer.rb | 88 +++++++--
spec/ruby/core/string/unpack/shared/unicode.rb | 14 +-
spec/ruby/core/string/unpack/w_spec.rb | 14 +-
spec/ruby/core/string/unpack1_spec.rb | 12 +-
spec/ruby/core/string/unpack_spec.rb | 34 ++++
spec/ruby/core/string/upcase_spec.rb | 4 +
spec/ruby/core/string/valid_encoding/utf_8_spec.rb | 214 +++++++++++++++++++++
spec/ruby/core/struct/values_at_spec.rb | 55 +++++-
spec/ruby/core/symbol/shared/id2name.rb | 7 +
spec/ruby/core/time/at_spec.rb | 16 ++
spec/ruby/core/time/localtime_spec.rb | 16 +-
spec/ruby/core/time/new_spec.rb | 94 +++++++--
spec/ruby/core/time/shared/gmtime.rb | 4 +-
spec/ruby/core/time/shared/time_params.rb | 11 +-
spec/ruby/core/time/strftime_spec.rb | 40 +++-
spec/ruby/core/time/utc_spec.rb | 41 +++-
spec/ruby/core/time/zone_spec.rb | 20 +-
spec/ruby/core/tracepoint/inspect_spec.rb | 9 +
spec/ruby/fixtures/code/load_wrap_fixture.rb | 12 ++
spec/ruby/fixtures/code/wrap_fixture.rb | 9 -
spec/ruby/language/case_spec.rb | 4 +-
.../ruby/language/regexp/character_classes_spec.rb | 5 +
spec/ruby/library/coverage/running_spec.rb | 20 ++
spec/ruby/library/date/civil_spec.rb | 7 +-
spec/ruby/library/objectspace/fixtures/trace.rb | 5 +
spec/ruby/library/objectspace/trace_spec.rb | 15 ++
spec/ruby/library/openssl/x509/name/verify_spec.rb | 4 +-
spec/ruby/library/stringio/initialize_spec.rb | 85 ++++++++
spec/ruby/library/stringio/new_spec.rb | 8 +
spec/ruby/library/stringio/shared/write.rb | 22 +++
spec/ruby/optional/capi/ext/io_spec.c | 43 +++++
spec/ruby/optional/capi/io_spec.rb | 15 ++
spec/ruby/shared/rational/Rational.rb | 48 ++---
114 files changed, 1963 insertions(+), 245 deletions(-)
create mode 100644 spec/ruby/core/marshal/fixtures/classes.rb
create mode 100644 spec/ruby/core/refinement/import_methods_spec.rb
create mode 100644 spec/ruby/core/refinement/include_spec.rb
create mode 100644 spec/ruby/core/refinement/prepend_spec.rb
create mode 100644 spec/ruby/core/string/unpack_spec.rb
create mode 100644 spec/ruby/core/string/valid_encoding/utf_8_spec.rb
create mode 100644 spec/ruby/fixtures/code/load_wrap_fixture.rb
delete mode 100644 spec/ruby/fixtures/code/wrap_fixture.rb
create mode 100644 spec/ruby/library/coverage/running_spec.rb
create mode 100644 spec/ruby/library/objectspace/fixtures/trace.rb
create mode 100644 spec/ruby/library/objectspace/trace_spec.rb
create mode 100644 spec/ruby/library/stringio/new_spec.rb
Diffstat (limited to 'spec/ruby/core/array/pack/shared')
| -rw-r--r-- | spec/ruby/core/array/pack/shared/basic.rb | 40 | ||||
| -rw-r--r-- | spec/ruby/core/array/pack/shared/float.rb | 66 | ||||
| -rw-r--r-- | spec/ruby/core/array/pack/shared/integer.rb | 96 | ||||
| -rw-r--r-- | spec/ruby/core/array/pack/shared/numeric_basic.rb | 10 | ||||
| -rw-r--r-- | spec/ruby/core/array/pack/shared/unicode.rb | 14 |
5 files changed, 196 insertions, 30 deletions
diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb index 23e239d3de..65fdaa45d8 100644 --- a/spec/ruby/core/array/pack/shared/basic.rb +++ b/spec/ruby/core/array/pack/shared/basic.rb @@ -27,6 +27,42 @@ describe :array_pack_basic_non_float, shared: true do [@obj, @obj].pack("a \t\n\v\f\r"+pack_format).should be_an_instance_of(String) end + it "ignores comments in the format string" do + # 2 additional directives ('a') are required for the X directive + [@obj, @obj, @obj, @obj].pack("aa #{pack_format} # some comment \n#{pack_format}").should be_an_instance_of(String) + end + + ruby_version_is ""..."3.2" do + it "warns in verbose mode 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'/, verbose: true) + -> { [@obj, @obj].pack("a 0" + pack_format) }.should complain(/unknown pack directive '0'/, verbose: true) + -> { [@obj, @obj].pack("a :" + pack_format) }.should complain(/unknown pack directive ':'/, verbose: true) + end + end + + ruby_version_is "3.2"..."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 ':'/) + 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) + -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError) + -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError) + end + end + it "calls #to_str to coerce the directives string" do d = mock("pack directive") d.should_receive(:to_str).and_return("x"+pack_format) @@ -39,6 +75,10 @@ describe :array_pack_basic_float, shared: true do [9.3, 4.7].pack(" \t\n\v\f\r"+pack_format).should be_an_instance_of(String) end + it "ignores comments in the format string" do + [9.3, 4.7].pack(pack_format + "# some comment \n" + pack_format).should be_an_instance_of(String) + end + it "calls #to_str to coerce the directives string" do d = mock("pack directive") d.should_receive(:to_str).and_return("x"+pack_format) diff --git a/spec/ruby/core/array/pack/shared/float.rb b/spec/ruby/core/array/pack/shared/float.rb index ba174a071a..9510cffed7 100644 --- a/spec/ruby/core/array/pack/shared/float.rb +++ b/spec/ruby/core/array/pack/shared/float.rb @@ -25,8 +25,18 @@ describe :array_pack_float_le, shared: true do [2.9, 1.4, 8.2].pack(pack_format("*")).should == "\x9a\x999@33\xb3?33\x03A" end - it "ignores NULL bytes between directives" do - [5.3, 9.2].pack(pack_format("\000", 2)).should == "\x9a\x99\xa9@33\x13A" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + [5.3, 9.2].pack(pack_format("\000", 2)).should == "\x9a\x99\xa9@33\x13A" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [5.3, 9.2].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -74,6 +84,11 @@ describe :array_pack_float_be, shared: true do it "converts an Integer to a Float" do [8].pack(pack_format).should == "A\x00\x00\x00" + [bignum_value].pack(pack_format).should == "_\x80\x00\x00" + end + + it "converts a Rational to a Float" do + [Rational(8)].pack(pack_format).should == "A\x00\x00\x00" end it "raises a TypeError if passed a String representation of a floating point number" do @@ -88,8 +103,18 @@ describe :array_pack_float_be, shared: true do [2.9, 1.4, 8.2].pack(pack_format("*")).should == "@9\x99\x9a?\xb333A\x0333" end - it "ignores NULL bytes between directives" do - [5.3, 9.2].pack(pack_format("\000", 2)).should == "@\xa9\x99\x9aA\x1333" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + [5.3, 9.2].pack(pack_format("\000", 2)).should == "@\xa9\x99\x9aA\x1333" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [5.3, 9.2].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -129,6 +154,11 @@ describe :array_pack_double_le, shared: true do it "converts an Integer to a Float" do [8].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\x20@" + [bignum_value].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\xF0C" + end + + it "converts a Rational to a Float" do + [Rational(8)].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00 @" end it "raises a TypeError if passed a String representation of a floating point number" do @@ -143,8 +173,18 @@ describe :array_pack_double_le, shared: true do [2.9, 1.4, 8.2].pack(pack_format("*")).should == "333333\x07@ffffff\xf6?ffffff\x20@" end - it "ignores NULL bytes between directives" do - [5.3, 9.2].pack(pack_format("\000", 2)).should == "333333\x15@ffffff\x22@" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + [5.3, 9.2].pack(pack_format("\000", 2)).should == "333333\x15@ffffff\x22@" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [5.3, 9.2].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -202,8 +242,18 @@ describe :array_pack_double_be, shared: true do [2.9, 1.4, 8.2].pack(pack_format("*")).should == "@\x07333333?\xf6ffffff@\x20ffffff" end - it "ignores NULL bytes between directives" do - [5.3, 9.2].pack(pack_format("\000", 2)).should == "@\x15333333@\x22ffffff" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + [5.3, 9.2].pack(pack_format("\000", 2)).should == "@\x15333333@\x22ffffff" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [5.3, 9.2].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do diff --git a/spec/ruby/core/array/pack/shared/integer.rb b/spec/ruby/core/array/pack/shared/integer.rb index 6592f85022..d3ce9b5792 100644 --- a/spec/ruby/core/array/pack/shared/integer.rb +++ b/spec/ruby/core/array/pack/shared/integer.rb @@ -41,9 +41,19 @@ describe :array_pack_16bit_le, shared: true do str.should == "\x78\x65\xcd\xab\x21\x43" end - it "ignores NULL bytes between directives" do - str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - str.should == "\x78\x65\xcd\xab" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + str.should == "\x78\x65\xcd\xab" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -93,9 +103,19 @@ describe :array_pack_16bit_be, shared: true do str.should == "\x65\x78\xab\xcd\x43\x21" end - it "ignores NULL bytes between directives" do - str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - str.should == "\x65\x78\xab\xcd" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + str.should == "\x65\x78\xab\xcd" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -145,9 +165,19 @@ describe :array_pack_32bit_le, shared: true do str.should == "\x78\x65\x43\x12\xcd\xab\xf0\xde\x21\x43\x65\x78" end - it "ignores NULL bytes between directives" do - str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - str.should == "\x78\x65\x43\x12\xcd\xab\xf0\xde" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + str.should == "\x78\x65\x43\x12\xcd\xab\xf0\xde" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -197,9 +227,19 @@ describe :array_pack_32bit_be, shared: true do str.should == "\x12\x43\x65\x78\xde\xf0\xab\xcd\x78\x65\x43\x21" end - it "ignores NULL bytes between directives" do - str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - str.should == "\x12\x43\x65\x78\xde\xf0\xab\xcd" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + str.should == "\x12\x43\x65\x78\xde\xf0\xab\xcd" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -309,9 +349,19 @@ describe :array_pack_64bit_le, shared: true do str.should == "\x56\x78\x12\x34\xcd\xab\xf0\xde\xf0\xde\xba\xdc\x21\x43\x65\x78" end - it "ignores NULL bytes between directives" do - str = [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) - str.should == "\x56\x78\x12\x34\xcd\xab\xf0\xde\xf0\xde\xba\xdc\x21\x43\x65\x78" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + str = [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) + str.should == "\x56\x78\x12\x34\xcd\xab\xf0\xde\xf0\xde\xba\xdc\x21\x43\x65\x78" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do @@ -369,9 +419,19 @@ describe :array_pack_64bit_be, shared: true do str.should == "\xde\xf0\xab\xcd\x34\x12\x78\x56\x78\x65\x43\x21\xdc\xba\xde\xf0" end - it "ignores NULL bytes between directives" do - str = [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) - str.should == "\xde\xf0\xab\xcd\x34\x12\x78\x56\x78\x65\x43\x21\xdc\xba\xde\xf0" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + str = [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) + str.should == "\xde\xf0\xab\xcd\x34\x12\x78\x56\x78\x65\x43\x21\xdc\xba\xde\xf0" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do diff --git a/spec/ruby/core/array/pack/shared/numeric_basic.rb b/spec/ruby/core/array/pack/shared/numeric_basic.rb index 7c36ba4a32..545e215e64 100644 --- a/spec/ruby/core/array/pack/shared/numeric_basic.rb +++ b/spec/ruby/core/array/pack/shared/numeric_basic.rb @@ -37,8 +37,14 @@ describe :array_pack_float, shared: true do -> { ["a"].pack(pack_format) }.should raise_error(TypeError) end - it "raises a TypeError when the object does not respond to #to_f" do - obj = mock('not an float') + it "raises a TypeError when the object is not Numeric" do + obj = Object.new + -> { [obj].pack(pack_format) }.should raise_error(TypeError, /can't convert Object into Float/) + end + + it "raises a TypeError when the Numeric object does not respond to #to_f" do + klass = Class.new(Numeric) + obj = klass.new -> { [obj].pack(pack_format) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/array/pack/shared/unicode.rb b/spec/ruby/core/array/pack/shared/unicode.rb index dd0f8b38aa..130c447bb7 100644 --- a/spec/ruby/core/array/pack/shared/unicode.rb +++ b/spec/ruby/core/array/pack/shared/unicode.rb @@ -67,8 +67,18 @@ describe :array_pack_unicode, shared: true do -> { [obj].pack("U") }.should raise_error(TypeError) end - it "ignores NULL bytes between directives" do - [1, 2, 3].pack("U\x00U").should == "\x01\x02" + ruby_version_is ""..."3.3" do + it "ignores NULL bytes between directives" do + [1, 2, 3].pack("U\x00U").should == "\x01\x02" + end + end + + ruby_version_is "3.3" do + it "raise ArgumentError for NULL bytes between directives" do + -> { + [1, 2, 3].pack("U\x00U") + }.should raise_error(ArgumentError, /unknown pack directive/) + end end it "ignores spaces between directives" do |
