Index: C:/Documents and Settings/Imran/workspace2/math/src/test/java/tests/api/java/math/BigDecimalTest.java =================================================================== --- C:/Documents and Settings/Imran/workspace2/math/src/test/java/tests/api/java/math/BigDecimalTest.java (revision 567170) +++ C:/Documents and Settings/Imran/workspace2/math/src/test/java/tests/api/java/math/BigDecimalTest.java (working copy) @@ -23,6 +23,8 @@ import java.io.ObjectOutputStream; import java.math.BigDecimal; import java.math.BigInteger; +import java.math.MathContext; +import java.math.RoundingMode; public class BigDecimalTest extends junit.framework.TestCase { @@ -911,9 +913,43 @@ ); /* Zero */ + //regression for HARMONY-4623, NON-BUG DIFF with RI BigDecimal zerotest = new BigDecimal("0.0000"); assertTrue("stripTrailingZero failed for 0.0000", ((zerotest.stripTrailingZeros()).scale() == 0) ); } + + public void testMathContextConstruction() + { + String a = "-12380945E+61"; + BigDecimal aNumber = new BigDecimal(a); + int precision = 6; + RoundingMode rm = RoundingMode.HALF_DOWN; + MathContext mcIntRm = new MathContext(precision, rm); + MathContext mcStr = new MathContext("precision=6 roundingMode=HALF_DOWN"); + MathContext mcInt = new MathContext(precision); + BigDecimal res = aNumber.abs(mcInt); + assertEquals("MathContext Constructer with int precision failed", + res, + new BigDecimal("1.23809E+68")); + + assertEquals("Equal MathContexts are not Equal ", + mcIntRm, + mcStr); + + assertEquals("Different MathContext are reported as Equal ", + mcInt.equals(mcStr), + false); + + assertEquals("Equal MathContexts have different hashcodes ", + mcIntRm.hashCode(), + mcStr.hashCode()); + + assertEquals("MathContext.toString() returning incorrect value", + mcIntRm.toString(), + "precision=6 roundingMode=HALF_DOWN"); + + + } }