summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-07-16 18:29:49 +0200
committerGitHub <noreply@github.com>2021-07-16 18:29:49 +0200
commit25efb5386293540b0542833625d3fb6e22f3cfbc (patch)
tree25ca5aacad698f049871fab78c42d2add3fcf2c0 /tests
parent96a7f9b31c84f14906b201d5e3b17c93d3878af6 (diff)
downloadNim-25efb5386293540b0542833625d3fb6e22f3cfbc.tar.gz
make dragonbox opt-in via -d:nimFpRoundtrips (#18504)
* make dragonbox opt-in via -d:nimFpRoundtrips

* make tests green again

* make tests green again
Diffstat (limited to 'tests')
-rw-r--r--tests/errmsgs/treportunused.nim14
-rw-r--r--tests/float/nim.cfg1
-rw-r--r--tests/float/tfloats.nim4
-rw-r--r--tests/stdlib/tjson.nim6
-rw-r--r--tests/stdlib/tjsonutils.nim21
5 files changed, 27 insertions, 19 deletions
diff --git a/tests/errmsgs/treportunused.nim b/tests/errmsgs/treportunused.nim
index 65e00163b..f9b7c3d11 100644
--- a/tests/errmsgs/treportunused.nim
+++ b/tests/errmsgs/treportunused.nim
@@ -13,12 +13,12 @@ treportunused.nim(30, 5) Hint: 's8' is declared but not used [XDeclaredButNotUse
 treportunused.nim(31, 5) Hint: 's9' is declared but not used [XDeclaredButNotUsed]
 treportunused.nim(32, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
 treportunused.nim(33, 6) Hint: 's11' is declared but not used [XDeclaredButNotUsed]
-treportunused.nim(37, 3) Hint: 'v0.99' is declared but not used [XDeclaredButNotUsed]
-treportunused.nim(38, 3) Hint: 'v0.99.99' is declared but not used [XDeclaredButNotUsed]
 '''
 action: compile
 """
 
+#treportunused.nim(37, 3) Hint: 'v0.99' is declared but not used [XDeclaredButNotUsed]
+#treportunused.nim(38, 3) Hint: 'v0.99.99' is declared but not used [XDeclaredButNotUsed]
 # bug #9764
 iterator s1(a:string): int = discard
 iterator s2(): int = discard
@@ -32,7 +32,9 @@ var s9: int
 type s10 = object
 type s11 = type(1.2)
 
-# https://github.com/nim-lang/Nim/issues/14407
-let
-  `v0.99` = "0.99"
-  `v0.99.99` = "0.99.99"
+when false:
+  # enabled again when Nim bootstraps with -d:nimFpRoundtrips
+  # https://github.com/nim-lang/Nim/issues/14407
+  let
+    `v0.99` = "0.99"
+    `v0.99.99` = "0.99.99"
diff --git a/tests/float/nim.cfg b/tests/float/nim.cfg
new file mode 100644
index 000000000..d27bbf43b
--- /dev/null
+++ b/tests/float/nim.cfg
@@ -0,0 +1 @@
+-d:nimFpRoundtrips
diff --git a/tests/float/tfloats.nim b/tests/float/tfloats.nim
index 406ddb6d9..30d9c50d6 100644
--- a/tests/float/tfloats.nim
+++ b/tests/float/tfloats.nim
@@ -66,6 +66,8 @@ template main =
     var a = 1.1'f32
     doAssert $a == "1.1", $a # was failing
 
+proc runtimeOnlyTests =
+  # enable for 'static' once -d:nimFpRoundtrips became the default
   block: # bug #7717
     proc test(f: float) =
       let f2 = $f
@@ -82,3 +84,5 @@ template main =
 
 static: main()
 main()
+
+runtimeOnlyTests()
diff --git a/tests/stdlib/tjson.nim b/tests/stdlib/tjson.nim
index 289ef9d05..000f72038 100644
--- a/tests/stdlib/tjson.nim
+++ b/tests/stdlib/tjson.nim
@@ -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)])"""
 
-block: # bug #17383
+when defined(nimFpRoundtrips): # bug #17383
   testRoundtrip(int32.high): "2147483647"
   testRoundtrip(uint32.high): "4294967295"
   when int.sizeof == 4:
@@ -316,7 +316,7 @@ block: # bug #17383
     testRoundtrip(int64.high): "9223372036854775807"
     testRoundtrip(uint64.high): "18446744073709551615"
 
-block: # bug #18007
+when defined(nimFpRoundtrips): # 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 @@ block: # bug #18007
     testRoundtripVal(0.0): "0.0"
     testRoundtripVal(-0.0): "-0.0"
 
-block: # bug #15397, bug #13196
+when defined(nimFpRoundtrips): # bug #15397, bug #13196
   testRoundtripVal(1.0 + epsilon(float64)): "1.0000000000000002"
   testRoundtripVal(0.12345678901234567890123456789): "0.12345678901234568"
 
diff --git a/tests/stdlib/tjsonutils.nim b/tests/stdlib/tjsonutils.nim
index b0c444cbf..3e9c422e0 100644
--- a/tests/stdlib/tjsonutils.nim
+++ b/tests/stdlib/tjsonutils.nim
@@ -44,7 +44,7 @@ proc `$`(a: MyEnum): string =
   if a == me2: "me2Modif"
   else: system.`$`(a)
 
-template fn() = 
+template fn() =
   block: # toJson, jsonTo
     type Foo = distinct float
     testRoundtrip('x', """120""")
@@ -161,15 +161,16 @@ template fn() =
     doAssert b[2].signbit
     doAssert not b[3].signbit
 
-  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]"
+  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]"
 
-    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
@@ -433,7 +434,7 @@ template fn() =
           """{"b": true, "bt": false, "btf": "test"}"""
         testRoundtrip(Variant(b: true, bt: true, btt: 'c')):
           """{"b": true, "bt": true, "btt": "c"}"""
-        
+
         # TODO: Add additional tests with missing and extra JSON keys, both when
         # allowed and forbidden analogous to the tests for the not nested
         # variant objects.