rename nimFpRoundtrips => nimPreviewFloatRoundtrip (#18566)

This commit is contained in:
Timothee Cour
2021-07-23 14:57:47 -07:00
committed by GitHub
parent faabcfa643
commit cc0f02d57d
6 changed files with 12 additions and 12 deletions

View File

@@ -112,8 +112,8 @@
- `system.addFloat` and `system.$` now can produce string representations of floating point numbers
that are minimal in size and that "roundtrip" (via the "Dragonbox" algorithm). This currently has
to be enabled via `-d:nimFpRoundtrips`. It is expected that this behavior becomes the new default
in upcoming versions.
to be enabled via `-d:nimPreviewFloatRoundtrip`. It is expected that this behavior becomes the new default
in upcoming versions, as with other `nimPreviewX` define flags.
- Fixed buffer overflow bugs in `net`

View File

@@ -4,7 +4,7 @@ hint:XDeclaredButNotUsed:off
define:booting
define:nimcore
define:nimFpRoundtrips
define:nimPreviewFloatRoundtrip
#import:"$projectpath/testability"

View File

@@ -74,7 +74,7 @@ proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat):
result = 3
proc writeFloatToBuffer*(buf: var array[65, char]; value: BiggestFloat | float32): int {.inline.} =
when defined(nimFpRoundtrips):
when defined(nimPreviewFloatRoundtrip):
writeFloatToBufferRoundtrip(buf, value)
else:
writeFloatToBufferSprintf(buf, value)
@@ -121,7 +121,7 @@ proc addFloat*(result: var string; x: float | float32) {.inline.} =
s.addFloat(45.67)
assert s == "foo:45.67"
template impl =
when defined(nimFpRoundtrips):
when defined(nimPreviewFloatRoundtrip):
addFloatRoundtrip(result, x)
else:
addFloatSprintf(result, x)

View File

@@ -35,4 +35,4 @@ switch("define", "nimExperimentalAsyncjsThen")
switch("define", "nimExperimentalJsfetch")
switch("define", "nimExperimentalLinenoiseExtra")
switch("define", "nimFpRoundtrips")
switch("define", "nimPreviewFloatRoundtrip")

View File

@@ -32,7 +32,7 @@ var s9: int
type s10 = object
type s11 = type(1.2)
# bug #14407 (requires `compiler/nim.cfg` containing define:nimFpRoundtrips)
# bug #14407 (requires `compiler/nim.cfg` containing define:nimPreviewFloatRoundtrip)
let
`v0.99` = "0.99"
`v0.99.99` = "0.99.99"

View File

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