summary refs log tree commit diff stats
path: root/tests/stdlib/tmath_misc.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib/tmath_misc.nim')
-rw-r--r--tests/stdlib/tmath_misc.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/stdlib/tmath_misc.nim b/tests/stdlib/tmath_misc.nim
new file mode 100644
index 000000000..978e3e94d
--- /dev/null
+++ b/tests/stdlib/tmath_misc.nim
@@ -0,0 +1,24 @@
+discard """
+  targets: "c js"
+"""
+
+# TODO merge this to tmath.nim once tmath.nim supports js target
+
+import math
+
+proc main() =
+  block:
+    doAssert 1.0 / abs(-0.0) == Inf
+    doAssert 1.0 / abs(0.0) == Inf
+    doAssert -1.0 / abs(-0.0) == -Inf
+    doAssert -1.0 / abs(0.0) == -Inf
+    doAssert abs(0.0) == 0.0
+    doAssert abs(0.0'f32) == 0.0'f32
+
+    doAssert abs(Inf) == Inf
+    doAssert abs(-Inf) == Inf
+    doAssert abs(NaN).isNaN
+    doAssert abs(-NaN).isNaN
+
+static: main()
+main()