harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r372905 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Collections.java test/java/org/apache/harmony/tests/java/util/CollectionsTest.java
Date Fri, 27 Jan 2006 16:52:23 GMT
Author: tellison
Date: Fri Jan 27 08:52:11 2006
New Revision: 372905

URL: http://svn.apache.org/viewcvs?rev=372905&view=rev
Log:
Fix for HARMONY-20 (java.util.Collections rotate() gives incorrect result with distance parameter
of min possible integer value)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/util/CollectionsTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java?rev=372905&r1=372904&r2=372905&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
Fri Jan 27 08:52:11 2006
@@ -1787,7 +1787,7 @@
 		if (dist > 0)
 			normdist = dist % size;
 		else
-			normdist = size - (dist * (-1) % size);
+			normdist = size - ((dist % size) * (-1));
 
 		if (normdist == 0 || normdist == size)
 			return;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/util/CollectionsTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/util/CollectionsTest.java?rev=372905&r1=372904&r2=372905&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/util/CollectionsTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/util/CollectionsTest.java
Fri Jan 27 08:52:11 2006
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 
 import junit.framework.TestCase;
 
@@ -29,5 +30,25 @@
 	public void test_rotateLjava_util_ListI() {
 		// Regression for HARMONY-19 Rotate an *empty* list
 		Collections.rotate(new ArrayList(), 25);
+		
+		// Regression for HARMONY-20
+		List list = new ArrayList();
+		list.add(0, "zero");
+		list.add(1, "one");
+		list.add(2, "two");
+		list.add(3, "three");
+		list.add(4, "four");
+
+		Collections.rotate(list, Integer.MIN_VALUE);
+		assertEquals("Rotated incorrectly at position 0, ", "three",
+				(String) list.get(0));
+		assertEquals("Rotated incorrectly at position 1, ", "four",
+				(String) list.get(1));
+		assertEquals("Rotated incorrectly at position 2, ", "zero",
+				(String) list.get(2));
+		assertEquals("Rotated incorrectly at position 3, ", "one",
+				(String) list.get(3));
+		assertEquals("Rotated incorrectly at position 4, ", "two",
+				(String) list.get(4));
 	}
 }



Mime
View raw message