summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-02-22 02:14:18 -0600
committerGitHub <noreply@github.com>2021-02-22 09:14:18 +0100
commit32bf10126c0e9d75e4b17034d32025e7682f5ec1 (patch)
treeec6415f40d9cd5dbb43585ae11ec7422a91ef16b
parentcde950e1bc4f8fa3ac9b243cb6117dab1eab3645 (diff)
downloadNim-32bf10126c0e9d75e4b17034d32025e7682f5ec1.tar.gz
fix #17118 (#17119) [backport:1.2]
* fix js unsigned integer
* Use `std` prefix for standard library modules
* fix #17118
-rw-r--r--compiler/vmops.nim11
-rw-r--r--tests/stdlib/tmath.nim38
2 files changed, 30 insertions, 19 deletions
diff --git a/compiler/vmops.nim b/compiler/vmops.nim
index b49901ee2..807d4d9b5 100644
--- a/compiler/vmops.nim
+++ b/compiler/vmops.nim
@@ -11,7 +11,8 @@
 #import vmdeps, vm
 from std/math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
   arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc,
-  floor, ceil, `mod`
+  floor, ceil, `mod`, cbrt, arcsinh, arccosh, arctanh, erf, erfc, gamma,
+  lgamma
 
 when declared(math.copySign):
   from std/math import copySign
@@ -159,6 +160,7 @@ proc registerAdditionalOps*(c: PCtx) =
     setResult a, c.config.projectPath.string
 
   wrap1f_math(sqrt)
+  wrap1f_math(cbrt)
   wrap1f_math(ln)
   wrap1f_math(log10)
   wrap1f_math(log2)
@@ -166,6 +168,9 @@ proc registerAdditionalOps*(c: PCtx) =
   wrap1f_math(arccos)
   wrap1f_math(arcsin)
   wrap1f_math(arctan)
+  wrap1f_math(arcsinh)
+  wrap1f_math(arccosh)
+  wrap1f_math(arctanh)
   wrap2f_math(arctan2)
   wrap1f_math(cos)
   wrap1f_math(cosh)
@@ -178,6 +183,10 @@ proc registerAdditionalOps*(c: PCtx) =
   wrap1f_math(trunc)
   wrap1f_math(floor)
   wrap1f_math(ceil)
+  wrap1f_math(erf)
+  wrap1f_math(erfc)
+  wrap1f_math(gamma)
+  wrap1f_math(lgamma)
 
   when declared(copySign):
     wrap2f_math(copySign)
diff --git a/tests/stdlib/tmath.nim b/tests/stdlib/tmath.nim
index 769d89b64..350ee59e9 100644
--- a/tests/stdlib/tmath.nim
+++ b/tests/stdlib/tmath.nim
@@ -11,26 +11,28 @@ import std/math
 # Function for approximate comparison of floats
 proc `==~`(x, y: float): bool = abs(x - y) < 1e-9
 
-block:
-  when not defined(js):
-    # check for no side effect annotation
-    proc mySqrt(num: float): float {.noSideEffect.} =
-      # xxx unused
-      sqrt(num)
-
-    # check gamma function
-    doAssert gamma(5.0) == 24.0 # 4!
-    doAssert almostEqual(gamma(0.5), sqrt(PI))
-    doAssert almostEqual(gamma(-0.5), -2 * sqrt(PI))
-    doAssert lgamma(1.0) == 0.0 # ln(1.0) == 0.0
-    doAssert almostEqual(lgamma(0.5), 0.5 * ln(PI))
-    doAssert erf(6.0) > erf(5.0)
-    doAssert erfc(6.0) < erfc(5.0)
-
-when not defined(js) and not defined(windows): # xxx pending bug #17017
-  doAssert gamma(-1.0).isNaN
 
 template main() =
+  block:
+    when not defined(js):
+      # check for no side effect annotation
+      proc mySqrt(num: float): float {.noSideEffect.} =
+        # xxx unused
+        sqrt(num)
+
+      # check gamma function
+      doAssert gamma(5.0) == 24.0 # 4!
+      doAssert almostEqual(gamma(0.5), sqrt(PI))
+      doAssert almostEqual(gamma(-0.5), -2 * sqrt(PI))
+      doAssert lgamma(1.0) == 0.0 # ln(1.0) == 0.0
+      doAssert almostEqual(lgamma(0.5), 0.5 * ln(PI))
+      doAssert erf(6.0) > erf(5.0)
+      doAssert erfc(6.0) < erfc(5.0)
+
+  when not defined(js) and not defined(windows): # xxx pending bug #17017
+    doAssert gamma(-1.0).isNaN
+
+
   block: # sgn() tests
     doAssert sgn(1'i8) == 1
     doAssert sgn(1'i16) == 1