* fix js unsigned integer * Use `std` prefix for standard library modules * fix #17118
This commit is contained in:
parent
cde950e1bc
commit
32bf10126c
2 changed files with 30 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue