Skip to content

Commit 7317f96

Browse files
andrykonchineregon
andauthored
Move out from quarantine a Marshal.dump spec for Float (ruby#12692)
* Move out from quarantine a Marshal.dump spec for Float Co-authored-by: Benoit Daloze <[email protected]>
1 parent 1683dad commit 7317f96

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

spec/ruby/core/marshal/dump_spec.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,20 @@ def _dump(level)
286286
].should be_computed_by(:dump)
287287
end
288288

289-
quarantine! do # fails on i686 with 'Expected "\x04\b[\af\x060f\x060" == "\x04\b[\af\x060@\x06" to be truthy but was false'
290-
it "uses object links for objects repeatedly dumped" do
291-
Marshal.dump([0.0, 0.0]).should == "\x04\b[\af\x060@\x06" # @\x06 is a link to the float value
289+
it "may or may not use object links for objects repeatedly dumped" do
290+
# it's an MRI implementation detail - on x86 architecture object links
291+
# aren't used for Float values but on amd64 - object links are used
292+
293+
dump = Marshal.dump([0.0, 0.0])
294+
["\x04\b[\af\x060@\x06", "\x04\b[\af\x060f\x060"].should.include?(dump)
295+
296+
# if object links aren't used - entries in the objects table are still
297+
# occupied by Float values
298+
if dump == "\x04\b[\af\x060f\x060"
299+
s = "string"
300+
# an index of "string" ("@\b") in the object table equals 3 (`"\b".ord - 5`),
301+
# so `0.0, 0,0` elements occupied indices 1 and 2
302+
Marshal.dump([0.0, 0.0, s, s]).should == "\x04\b[\tf\x060f\x060\"\vstring@\b"
292303
end
293304
end
294305
end

0 commit comments

Comments
 (0)