harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r567914 - in /harmony/enhanced/classlib/trunk/modules/math/src: main/java/java/math/Logical.java test/java/tests/api/java/math/BigDecimalTest.java test/java/tests/api/java/math/BigIntegerTest.java
Date Tue, 21 Aug 2007 02:33:57 GMT
Author: pyang
Date: Mon Aug 20 19:33:56 2007
New Revision: 567914

URL: http://svn.apache.org/viewvc?rev=567914&view=rev
Log:
Fix HARMONY-4653(BigInteger andNot() fails to throw NullPointerException on null paramer)

Modified:
    harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Logical.java
    harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
    harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Logical.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Logical.java?rev=567914&r1=567913&r2=567914&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Logical.java (original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Logical.java Mon
Aug 20 19:33:56 2007
@@ -224,12 +224,12 @@
     
     /** @see BigInteger#andNot(BigInteger) */
     static BigInteger andNot(BigInteger val, BigInteger that) {
-        if (val.sign == 0) {
-            return BigInteger.ZERO;
-        }
         if (that.sign == 0 ) {
             return val;
         }
+        if (val.sign == 0) {
+            return BigInteger.ZERO;
+        }
         if (val.equals(BigInteger.MINUS_ONE)) {
             return that.not();
         }
@@ -239,7 +239,7 @@
         
         //if val == that, return 0
         
-                    if (val.sign > 0) {
+       if (val.sign > 0) {
             if (that.sign > 0) {
                 return andNotPositive(val, that);
             } else {

Modified: harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java?rev=567914&r1=567913&r2=567914&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
Mon Aug 20 19:33:56 2007
@@ -911,6 +911,7 @@
 				);
 		
 		/* 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)

Modified: harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java?rev=567914&r1=567913&r2=567914&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigIntegerTest.java
Mon Aug 20 19:33:56 2007
@@ -857,6 +857,15 @@
 						(i1.testBit(i) && !i2.testBit(i)) == res.testBit(i));
             }
 		}
+        //regression for HARMONY-4653
+        try{
+            BigInteger.ZERO.andNot(null);
+            fail("should throw NPE");
+        }catch(Exception e){
+            //expected
+        }
+        BigInteger bi = new BigInteger(0, new byte[]{});
+        assertEquals(BigInteger.ZERO, bi.andNot(BigInteger.ZERO));
 	}
     
 



Mime
View raw message