Skip to content

Commit

Permalink
Skip some Math.atan2() tests.
Browse files Browse the repository at this point in the history
Linux `atan2(3)` man page says:

```
If  y is positive infinity (negative infinity) and x is positive infinity,
+pi/4 (-pi/4) is re‐ turned.
```

But on Microsoft VC/MinGW, `atan2()` returns `NaN` if either of
arguments is infinite. So we skip those tests on the platforms.
  • Loading branch information
matz committed Sep 3, 2020
1 parent 1ed0319 commit bf10c28
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mrbgems/mruby-math/test/math.rb
Expand Up @@ -209,17 +209,18 @@ def assert_float_and_int(exp_ary, act_ary)
assert_float(+Math::PI, Math.atan2(+0.0, -0.0))
assert_float(-Math::PI, Math.atan2(-0.0, -0.0))

assert_float(0, Math.atan2(0, 1))
assert_float(Math::PI / 4, Math.atan2(1, 1))
assert_float(Math::PI / 2, Math.atan2(1, 0))

inf = Float::INFINITY
skip "Math.atan2() return NaN" if Math.atan2(+inf, -inf).nan?
expected = 3.0 * Math::PI / 4.0
assert_float(+expected, Math.atan2(+inf, -inf))
assert_float(-expected, Math.atan2(-inf, -inf))
expected = Math::PI / 4.0
assert_float(+expected, Math.atan2(+inf, +inf))
assert_float(-expected, Math.atan2(-inf, +inf))

assert_float(0, Math.atan2(0, 1))
assert_float(Math::PI / 4, Math.atan2(1, 1))
assert_float(Math::PI / 2, Math.atan2(1, 0))
end

assert('Math.ldexp') do
Expand Down

0 comments on commit bf10c28

Please sign in to comment.