Skip to content

Commit 9c9313b

Browse files
committed
Add argument coerce assertion for all BigMath methods
1 parent ecf6996 commit 9c9313b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/bigdecimal/test_bigmath.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,33 @@ def test_e
3030
assert_converge_in_precision {|n| E(n) }
3131
end
3232

33+
def test_coerce_argument
34+
f = 0.8
35+
bd = BigDecimal(f)
36+
assert_equal(BigMath.exp(bd, N), BigMath.exp(f, N))
37+
assert_equal(BigMath.log(bd, N), BigMath.log(f, N))
38+
assert_equal(sqrt(bd, N), sqrt(f, N))
39+
assert_equal(cbrt(bd, N), cbrt(f, N))
40+
assert_equal(hypot(bd, bd, N), hypot(f, f, N))
41+
assert_equal(sin(bd, N), sin(f, N))
42+
assert_equal(cos(bd, N), cos(f, N))
43+
assert_equal(tan(bd, N), tan(f, N))
44+
assert_equal(asin(bd, N), asin(f, N))
45+
assert_equal(acos(bd, N), acos(f, N))
46+
assert_equal(atan(bd, N), atan(f, N))
47+
assert_equal(atan2(bd, bd, N), atan2(f, f, N))
48+
assert_equal(sinh(bd, N), sinh(f, N))
49+
assert_equal(cosh(bd, N), cosh(f, N))
50+
assert_equal(tanh(bd, N), tanh(f, N))
51+
assert_equal(asinh(bd, N), asinh(f, N))
52+
assert_equal(acosh(bd * 2, N), acosh(f * 2, N))
53+
assert_equal(atanh(bd, N), atanh(f, N))
54+
assert_equal(log2(bd, N), log2(f, N))
55+
assert_equal(log10(bd, N), log10(f, N))
56+
assert_equal(log1p(bd, N), log1p(f, N))
57+
assert_equal(expm1(bd, N), expm1(f, N))
58+
end
59+
3360
def test_sqrt
3461
assert_in_delta(2**0.5, sqrt(BigDecimal("2"), N))
3562
assert_equal(10, sqrt(BigDecimal("100"), N))

0 commit comments

Comments
 (0)