-d:nimPreviewFloatRoundtrip becomes the default (#24217)

This commit is contained in:
ringabout
2024-10-06 14:35:03 +08:00
committed by GitHub
parent 09043f409f
commit aa605da92a
6 changed files with 16 additions and 26 deletions

View File

@@ -1,5 +1,4 @@
discard """
matrix: "-d:nimPreviewFloatRoundtrip; -u:nimPreviewFloatRoundtrip"
targets: "c cpp js"
"""
@@ -66,29 +65,18 @@ template main =
block: # example 1
let a = 0.1+0.2
doAssert a != 0.3
when defined(nimPreviewFloatRoundtrip):
doAssert $a == "0.30000000000000004"
else:
whenRuntimeJs: discard
do: doAssert $a == "0.3"
doAssert $a == "0.30000000000000004"
block: # example 2
const a = 0.1+0.2
when defined(nimPreviewFloatRoundtrip):
doAssert $($a, a) == """("0.30000000000000004", 0.30000000000000004)"""
else:
whenRuntimeJs: discard
do: doAssert $($a, a) == """("0.3", 0.3)"""
doAssert $($a, a) == """("0.30000000000000004", 0.30000000000000004)"""
block: # example 3
const a1 = 0.1+0.2
let a2 = a1
doAssert a1 != 0.3
when defined(nimPreviewFloatRoundtrip):
doAssert $[$a1, $a2] == """["0.30000000000000004", "0.30000000000000004"]"""
else:
whenRuntimeJs: discard
do: doAssert $[$a1, $a2] == """["0.3", "0.3"]"""
doAssert $[$a1, $a2] == """["0.30000000000000004", "0.30000000000000004"]"""
when defined(nimPreviewFloatRoundtrip):
when true:
block: # bug #18148
var a = 1.1'f32
doAssert $a == "1.1", $a # was failing