Skip to content

Commit

Permalink
Move out from quarantine a Marshal.dump spec for Float (ruby#12692)
Browse files Browse the repository at this point in the history
* Move out from quarantine a Marshal.dump spec for Float

Co-authored-by: Benoit Daloze <[email protected]>
  • Loading branch information
andrykonchin and eregon authored Feb 3, 2025
1 parent 1683dad commit 7317f96
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spec/ruby/core/marshal/dump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,20 @@ def _dump(level)
].should be_computed_by(:dump)
end

quarantine! do # fails on i686 with 'Expected "\x04\b[\af\x060f\x060" == "\x04\b[\af\x060@\x06" to be truthy but was false'
it "uses object links for objects repeatedly dumped" do
Marshal.dump([0.0, 0.0]).should == "\x04\b[\af\x060@\x06" # @\x06 is a link to the float value
it "may or may not use object links for objects repeatedly dumped" do
# it's an MRI implementation detail - on x86 architecture object links
# aren't used for Float values but on amd64 - object links are used

dump = Marshal.dump([0.0, 0.0])
["\x04\b[\af\x060@\x06", "\x04\b[\af\x060f\x060"].should.include?(dump)

# if object links aren't used - entries in the objects table are still
# occupied by Float values
if dump == "\x04\b[\af\x060f\x060"
s = "string"
# an index of "string" ("@\b") in the object table equals 3 (`"\b".ord - 5`),
# so `0.0, 0,0` elements occupied indices 1 and 2
Marshal.dump([0.0, 0.0, s, s]).should == "\x04\b[\tf\x060f\x060\"\vstring@\b"
end
end
end
Expand Down

0 comments on commit 7317f96

Please sign in to comment.