diff options
Diffstat (limited to 'spec/ruby/core/string/unpack/shared/float.rb')
| -rw-r--r-- | spec/ruby/core/string/unpack/shared/float.rb | 84 |
1 files changed, 21 insertions, 63 deletions
diff --git a/spec/ruby/core/string/unpack/shared/float.rb b/spec/ruby/core/string/unpack/shared/float.rb index 93282bf4c9..5525c3fe73 100644 --- a/spec/ruby/core/string/unpack/shared/float.rb +++ b/spec/ruby/core/string/unpack/shared/float.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary describe :string_unpack_float_le, shared: true do it "decodes one float for a single format character" do @@ -53,24 +53,13 @@ describe :string_unpack_float_le, shared: true do it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end - ruby_version_is ""..."3.3" do - it "ignores NULL bytes between directives" do - suppress_warning do - array = "\x9a\x999@33\xb3?".unpack(unpack_format("\000", 2)) - array.should == [2.9000000953674316, 1.399999976158142] - end - end - end - - ruby_version_is "3.3" do - it "raise ArgumentError for NULL bytes between directives" do - -> { - "\x9a\x999@33\xb3?".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) - end + it "raise ArgumentError for NULL bytes between directives" do + -> { + "\x9a\x999@33\xb3?".unpack(unpack_format("\000", 2)) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -132,24 +121,13 @@ describe :string_unpack_float_be, shared: true do it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true - end - - ruby_version_is ""..."3.3" do - it "ignores NULL bytes between directives" do - suppress_warning do - array = "@9\x99\x9a?\xb333".unpack(unpack_format("\000", 2)) - array.should == [2.9000000953674316, 1.399999976158142] - end - end + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end - ruby_version_is "3.3" do - it "raise ArgumentError for NULL bytes between directives" do - -> { - "@9\x99\x9a?\xb333".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) - end + it "raise ArgumentError for NULL bytes between directives" do + -> { + "@9\x99\x9a?\xb333".unpack(unpack_format("\000", 2)) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -214,23 +192,13 @@ describe :string_unpack_double_le, shared: true do it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end - ruby_version_is ""..."3.3" do - it "ignores NULL bytes between directives" do - suppress_warning do - "333333\x07@ffffff\xf6?".unpack(unpack_format("\000", 2)).should == [2.9, 1.4] - end - end - end - - ruby_version_is "3.3" do - it "raise ArgumentError for NULL bytes between directives" do - -> { - "333333\x07@ffffff\xf6?".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) - end + it "raise ArgumentError for NULL bytes between directives" do + -> { + "333333\x07@ffffff\xf6?".unpack(unpack_format("\000", 2)) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -294,23 +262,13 @@ describe :string_unpack_double_be, shared: true do it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true - end - - ruby_version_is ""..."3.3" do - it "ignores NULL bytes between directives" do - suppress_warning do - "@\x07333333?\xf6ffffff".unpack(unpack_format("\000", 2)).should == [2.9, 1.4] - end - end + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end - ruby_version_is "3.3" do - it "raise ArgumentError for NULL bytes between directives" do - -> { - "@\x07333333?\xf6ffffff".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) - end + it "raise ArgumentError for NULL bytes between directives" do + -> { + "@\x07333333?\xf6ffffff".unpack(unpack_format("\000", 2)) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do |
