fix #17118 (#17119) [backport:1.2]

* fix js unsigned integer
* Use `std` prefix for standard library modules
* fix #17118
This commit is contained in:
flywind 2021-02-22 02:14:18 -06:00 • committed by GitHub
commit 32bf10126c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 19 deletions

View file

@ -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