From 7317f96727725ca37ddb06011918deb841de371c Mon Sep 17 00:00:00 2001 From: Andrii Konchyn Date: Mon, 3 Feb 2025 15:24:16 +0200 Subject: [PATCH] Move out from quarantine a Marshal.dump spec for Float (#12692) * Move out from quarantine a Marshal.dump spec for Float Co-authored-by: Benoit Daloze --- spec/ruby/core/marshal/dump_spec.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb index 1b05263e7d..cc5337b50e 100644 --- a/spec/ruby/core/marshal/dump_spec.rb +++ b/spec/ruby/core/marshal/dump_spec.rb @@ -286,9 +286,20 @@ describe "Marshal.dump" do ].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