rename nimFpRoundtrips => nimPreviewFloatRoundtrip (#18566)
This commit is contained in:
parent
faabcfa643
commit
cc0f02d57d
6 changed files with 12 additions and 12 deletions
|
|
@ -112,8 +112,8 @@
|
||||||
|
|
||||||
- `system.addFloat` and `system.$` now can produce string representations of floating point numbers
|
- `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
|
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
|
to be enabled via `-d:nimPreviewFloatRoundtrip`. It is expected that this behavior becomes the new default
|
||||||
in upcoming versions.
|
in upcoming versions, as with other `nimPreviewX` define flags.
|
||||||
|
|
||||||
- Fixed buffer overflow bugs in `net`
|
- Fixed buffer overflow bugs in `net`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ hint:XDeclaredButNotUsed:off
|
||||||
|
|
||||||
define:booting
|
define:booting
|
||||||
define:nimcore
|
define:nimcore
|
||||||
define:nimFpRoundtrips
|
define:nimPreviewFloatRoundtrip
|
||||||
|
|
||||||
#import:"$projectpath/testability"
|
#import:"$projectpath/testability"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ proc writeFloatToBufferSprintf*(buf: var array[65, char]; value: BiggestFloat):
|
||||||
result = 3
|
result = 3
|
||||||
|
|
||||||
proc writeFloatToBuffer*(buf: var array[65, char]; value: BiggestFloat | float32): int {.inline.} =
|
proc writeFloatToBuffer*(buf: var array[65, char]; value: BiggestFloat | float32): int {.inline.} =
|
||||||
when defined(nimFpRoundtrips):
|
when defined(nimPreviewFloatRoundtrip):
|
||||||
writeFloatToBufferRoundtrip(buf, value)
|
writeFloatToBufferRoundtrip(buf, value)
|
||||||
else:
|
else:
|
||||||
writeFloatToBufferSprintf(buf, value)
|
writeFloatToBufferSprintf(buf, value)
|
||||||
|
|
@ -121,7 +121,7 @@ proc addFloat*(result: var string; x: float | float32) {.inline.} =
|
||||||
s.addFloat(45.67)
|
s.addFloat(45.67)
|
||||||
assert s == "foo:45.67"
|
assert s == "foo:45.67"
|
||||||
template impl =
|
template impl =
|
||||||
when defined(nimFpRoundtrips):
|
when defined(nimPreviewFloatRoundtrip):
|
||||||
addFloatRoundtrip(result, x)
|
addFloatRoundtrip(result, x)
|
||||||
else:
|
else:
|
||||||
addFloatSprintf(result, x)
|
addFloatSprintf(result, x)
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,4 @@ switch("define", "nimExperimentalAsyncjsThen")
|
||||||
switch("define", "nimExperimentalJsfetch")
|
switch("define", "nimExperimentalJsfetch")
|
||||||
switch("define", "nimExperimentalLinenoiseExtra")
|
switch("define", "nimExperimentalLinenoiseExtra")
|
||||||
|
|
||||||
switch("define", "nimFpRoundtrips")
|
switch("define", "nimPreviewFloatRoundtrip")
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ var s9: int
|
||||||
type s10 = object
|
type s10 = object
|
||||||
type s11 = type(1.2)
|
type s11 = type(1.2)
|
||||||
|
|
||||||
# bug #14407 (requires `compiler/nim.cfg` containing define:nimFpRoundtrips)
|
# bug #14407 (requires `compiler/nim.cfg` containing define:nimPreviewFloatRoundtrip)
|
||||||
let
|
let
|
||||||
`v0.99` = "0.99"
|
`v0.99` = "0.99"
|
||||||
`v0.99.99` = "0.99.99"
|
`v0.99.99` = "0.99.99"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
matrix: "-d:nimFpRoundtrips; -u:nimFpRoundtrips"
|
matrix: "-d:nimPreviewFloatRoundtrip; -u:nimPreviewFloatRoundtrip"
|
||||||
targets: "c cpp js"
|
targets: "c cpp js"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -67,14 +67,14 @@ template main =
|
||||||
block: # example 1
|
block: # example 1
|
||||||
let a = 0.1+0.2
|
let a = 0.1+0.2
|
||||||
doAssert a != 0.3
|
doAssert a != 0.3
|
||||||
when defined(nimFpRoundtrips):
|
when defined(nimPreviewFloatRoundtrip):
|
||||||
doAssert $a == "0.30000000000000004"
|
doAssert $a == "0.30000000000000004"
|
||||||
else:
|
else:
|
||||||
whenRuntimeJs: discard
|
whenRuntimeJs: discard
|
||||||
do: doAssert $a == "0.3"
|
do: doAssert $a == "0.3"
|
||||||
block: # example 2
|
block: # example 2
|
||||||
const a = 0.1+0.2
|
const a = 0.1+0.2
|
||||||
when defined(nimFpRoundtrips):
|
when defined(nimPreviewFloatRoundtrip):
|
||||||
doAssert $($a, a) == """("0.30000000000000004", 0.30000000000000004)"""
|
doAssert $($a, a) == """("0.30000000000000004", 0.30000000000000004)"""
|
||||||
else:
|
else:
|
||||||
whenRuntimeJs: discard
|
whenRuntimeJs: discard
|
||||||
|
|
@ -83,13 +83,13 @@ template main =
|
||||||
const a1 = 0.1+0.2
|
const a1 = 0.1+0.2
|
||||||
let a2 = a1
|
let a2 = a1
|
||||||
doAssert a1 != 0.3
|
doAssert a1 != 0.3
|
||||||
when defined(nimFpRoundtrips):
|
when defined(nimPreviewFloatRoundtrip):
|
||||||
doAssert $[$a1, $a2] == """["0.30000000000000004", "0.30000000000000004"]"""
|
doAssert $[$a1, $a2] == """["0.30000000000000004", "0.30000000000000004"]"""
|
||||||
else:
|
else:
|
||||||
whenRuntimeJs: discard
|
whenRuntimeJs: discard
|
||||||
do: doAssert $[$a1, $a2] == """["0.3", "0.3"]"""
|
do: doAssert $[$a1, $a2] == """["0.3", "0.3"]"""
|
||||||
|
|
||||||
when defined(nimFpRoundtrips):
|
when defined(nimPreviewFloatRoundtrip):
|
||||||
block: # bug #18148
|
block: # bug #18148
|
||||||
var a = 1.1'f32
|
var a = 1.1'f32
|
||||||
doAssert $a == "1.1", $a # was failing
|
doAssert $a == "1.1", $a # was failing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue