make -d:nimFpRoundtrips work consistently in vm vs rt, fix #18400, etc (#18531)

* compiler/vmhooks: add getVar to allow vmops with var params
* addFloat vmops with var param
* cgen now renders float32 literals in c backend using roundtrip float to string
This commit is contained in:
Timothee Cour
2021-07-20 13:13:52 -07:00
committed by GitHub
parent a8b3e7c059
commit cf0cf32d27
21 changed files with 286 additions and 199 deletions

View File

@@ -303,7 +303,7 @@ let jsonNode = %*mynode
doAssert $jsonNode == """{"kind":"P","pChildren":[{"kind":"Text","textStr":"mychild"},{"kind":"Br"}]}"""
doAssert $jsonNode.to(ContentNode) == """(kind: P, pChildren: @[(kind: Text, textStr: "mychild"), (kind: Br)])"""
when defined(nimFpRoundtrips): # bug #17383
block: # bug #17383
testRoundtrip(int32.high): "2147483647"
testRoundtrip(uint32.high): "4294967295"
when int.sizeof == 4:
@@ -316,7 +316,7 @@ when defined(nimFpRoundtrips): # bug #17383
testRoundtrip(int64.high): "9223372036854775807"
testRoundtrip(uint64.high): "18446744073709551615"
when defined(nimFpRoundtrips): # bug #18007
block: # bug #18007
testRoundtrip([NaN, Inf, -Inf, 0.0, -0.0, 1.0]): """["nan","inf","-inf",0.0,-0.0,1.0]"""
# pending https://github.com/nim-lang/Nim/issues/18025 use:
# testRoundtrip([float32(NaN), Inf, -Inf, 0.0, -0.0, 1.0])
@@ -332,7 +332,7 @@ when defined(nimFpRoundtrips): # bug #18007
testRoundtripVal(0.0): "0.0"
testRoundtripVal(-0.0): "-0.0"
when defined(nimFpRoundtrips): # bug #15397, bug #13196
block: # bug #15397, bug #13196
testRoundtripVal(1.0 + epsilon(float64)): "1.0000000000000002"
testRoundtripVal(0.12345678901234567890123456789): "0.12345678901234568"

View File

@@ -161,16 +161,15 @@ template fn() =
doAssert b[2].signbit
doAssert not b[3].signbit
when defined(nimFpRoundtrips):
block: # bug #15397, bug #13196
let a = 0.1
let x = 0.12345678901234567890123456789
let b = (a + 0.2, 0.3, x)
testRoundtripVal(b): "[0.30000000000000004,0.3,0.12345678901234568]"
block: # bug #15397, bug #13196
let a = 0.1
let x = 0.12345678901234567890123456789
let b = (a + 0.2, 0.3, x)
testRoundtripVal(b): "[0.30000000000000004,0.3,0.12345678901234568]"
testRoundtripVal(0.12345678901234567890123456789): "0.12345678901234568"
testRoundtripVal(epsilon(float64)): "2.220446049250313e-16"
testRoundtripVal(1.0 + epsilon(float64)): "1.0000000000000002"
testRoundtripVal(0.12345678901234567890123456789): "0.12345678901234568"
testRoundtripVal(epsilon(float64)): "2.220446049250313e-16"
testRoundtripVal(1.0 + epsilon(float64)): "1.0000000000000002"
block: # case object
type Foo = object