diff options
Diffstat (limited to 'tests/float')
-rw-r--r-- | tests/float/tfloat4.nim | 12 | ||||
-rw-r--r-- | tests/float/tfloats.nim | 8 |
2 files changed, 12 insertions, 8 deletions
diff --git a/tests/float/tfloat4.nim b/tests/float/tfloat4.nim index 5bedca371..2bb61eb58 100644 --- a/tests/float/tfloat4.nim +++ b/tests/float/tfloat4.nim @@ -8,7 +8,7 @@ proc c_sprintf(buf, fmt: cstring) {.importc:"sprintf", header: "<stdio.h>", vara proc floatToStr(f: float64): string = var buffer: array[128, char] - c_sprintf(addr buffer, "%.16e", f) + c_sprintf(cast[cstring](addr buffer), "%.16e", f) result = "" for ch in buffer: if ch == '\0': @@ -56,8 +56,14 @@ doAssert 0.9999999999999999 == ".9999999999999999".parseFloat # bug #18400 var s = [-13.888888'f32] -assert $s[0] == "-13.888888" +doAssert $s[0] == "-13.888888" var x = 1.23456789012345'f32 -assert $x == "1.2345679" +doAssert $x == "1.2345679" + +# bug #21847 +doAssert parseFloat"0e+42" == 0.0 +doAssert parseFloat"0e+42949672969" == 0.0 +doAssert parseFloat"0e+42949672970" == 0.0 +doAssert parseFloat"0e+42949623223346323563272970" == 0.0 echo("passed all tests.") diff --git a/tests/float/tfloats.nim b/tests/float/tfloats.nim index 480396e81..aaed2d615 100644 --- a/tests/float/tfloats.nim +++ b/tests/float/tfloats.nim @@ -41,8 +41,7 @@ template main = test ".1", 0.1 test "-.1", -0.1 test "-0", -0.0 - when false: # pending bug #18246 - test "-0", -0.0 + test "-0", -0'f # see #18246, -0 won't work test ".1e-1", 0.1e-1 test "0_1_2_3.0_1_2_3E+0_1_2", 123.0123e12 test "0_1_2.e-0", 12e0 @@ -157,9 +156,8 @@ template main = when nimvm: discard # xxx, refs #12884 else: - when not defined(js): - doAssert x == 1.2345679'f32 - doAssert $x == "1.2345679" + doAssert x == 1.2345679'f32 + doAssert $x == "1.2345679" static: main() main() |