diff options
Diffstat (limited to 'tests/stdlib/tmath.nim')
-rw-r--r-- | tests/stdlib/tmath.nim | 38 |
1 files changed, 20 insertions, 18 deletions
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 |