Beef up Math log,log10,log1p,pow,exp tests. PiperOrigin-RevId: 363759816 Change-Id: I03a7923f4cb3d7eb8bf6d82b6f414d26bc8be0d4
diff --git a/user/test/com/google/gwt/emultest/java/lang/MathTest.java b/user/test/com/google/gwt/emultest/java/lang/MathTest.java index 50e4d1d..a163ce6 100644 --- a/user/test/com/google/gwt/emultest/java/lang/MathTest.java +++ b/user/test/com/google/gwt/emultest/java/lang/MathTest.java
@@ -366,18 +366,27 @@ double v = Math.log(Math.E); assertEquals(1.0, v, 1e-15); + + for (double d = -10; d < 10; d += 0.5) { + double answer = Math.log(Math.exp(d)); + assertEquals(d, answer, 0.000000001); + } } public void testLog10() { assertNaN(Math.log10(Double.NaN)); assertNaN(Math.log10(Double.NEGATIVE_INFINITY)); assertNaN(Math.log10(-1)); + assertNaN(Math.log10(-2541.057456872342)); + assertNaN(Math.log10(-0.1)); assertEquals(Double.POSITIVE_INFINITY, Math.log10(Double.POSITIVE_INFINITY)); assertEquals(Double.NEGATIVE_INFINITY, Math.log10(0.0)); assertEquals(Double.NEGATIVE_INFINITY, Math.log10(-0.0)); - - double v = Math.log10(1000.0); - assertEquals(3.0, v, 1e-15); + assertEquals(3.0, Math.log10(1000.0), 1e-15); + assertEquals(14.0, Math.log10(Math.pow(10, 14))); + assertEquals(3.73895612695404, Math.log10(5482.2158), 1e-15); + assertEquals(308.25471555991675, Math.log10(Double.MAX_VALUE)); + assertEquals(-323.30621534311575, Math.log10(Double.MIN_VALUE), 1e-10); } public void testLog1p() { @@ -386,11 +395,16 @@ assertNaN(Math.log1p(Double.NEGATIVE_INFINITY)); assertEquals(Double.POSITIVE_INFINITY, Math.log1p(Double.POSITIVE_INFINITY)); assertEquals(Double.NEGATIVE_INFINITY, Math.log1p(-1)); + assertEquals(Double.MIN_VALUE, Math.log1p(Double.MIN_VALUE), 1e-25); + assertEquals(709.782712893384, Math.log1p(Double.MAX_VALUE)); assertPositiveZero(Math.log1p(0.0)); assertNegativeZero(Math.log1p(-0.0)); assertEquals(-0.693147180, Math.log1p(-0.5), 1e-7); assertEquals(1.313261687, Math.log1p(Math.E), 1e-7); + assertEquals(-0.2941782295312541, Math.log1p(-0.254856327), 1e-7); + assertEquals(7.368050685564151, Math.log1p(1583.542)); + assertEquals(0.4633708685409921, Math.log1p(0.5894227), 1e-15); } public void testPow() { @@ -427,6 +441,7 @@ assertEquals(Double.POSITIVE_INFINITY, Math.pow(Double.NEGATIVE_INFINITY, 2)); assertEquals(Double.NEGATIVE_INFINITY, Math.pow(-0.0, -1)); assertEquals(Double.NEGATIVE_INFINITY, Math.pow(Double.NEGATIVE_INFINITY, 1)); + assertEquals(Double.NEGATIVE_INFINITY, Math.pow(-10.0, 3.093403029238847E15)); assertEquals(9, Math.pow(3, 2)); }