From 21a6776ac5b782615aecead4453480be0619e21e Mon Sep 17 00:00:00 2001 From: John Wostenberg Date: Fri, 13 Dec 2024 15:23:39 -0600 Subject: [PATCH] Add failing test case demonstrating sprintf negative zero bug #15557 --- .../FSharp.Core/Microsoft.FSharp.Core/PrintfTests.fs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/PrintfTests.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/PrintfTests.fs index 187fa62c60e..622e5370cbc 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/PrintfTests.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/PrintfTests.fs @@ -75,6 +75,16 @@ type PrintfTests() = Assert.AreEqual(" 7B", sprintf "%*X" 8 123 ) Assert.AreEqual("7B ", sprintf "%-*X" 8 123 ) + + [] + member this.``positive and negative zero``() = + test "%f" +0.0 "0.000000" + test "%f" -0.0 "-0.000000" + test "%f" -0.0000001 "-0.000000" + test "%+f" +0.0 "+0.000000" + test "%+f" -0.0 "-0.000000" + test "%+f" -0.0000001 "-0.000000" + [] member _.``union case formatting`` () = Assert.AreEqual("CaseOne", sprintf "%A" CaseOne)