changeset 5851:1dea2f94eed3 it2-bootstrap

ToArrayOp fixes
author mduigou
date Tue, 14 Aug 2012 12:27:32 -0700
parents 8a0c6d378c2d
children 009f78681526
files src/share/classes/java/util/streams/ops/ToArrayOp.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/ToArrayOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/UniqOpTest.java
diffstat 3 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/streams/ops/ToArrayOp.java	Tue Aug 14 10:29:46 2012 -0700
+++ b/src/share/classes/java/util/streams/ops/ToArrayOp.java	Tue Aug 14 12:27:32 2012 -0700
@@ -24,7 +24,6 @@
  */
 package java.util.streams.ops;
 
-import com.sun.tools.classfile.ConstantPool;
 import java.util.Arrays;
 import java.util.streams.ParallelStreamable;
 import java.util.streams.StatefulSink;
@@ -59,7 +58,7 @@
             public void accept(T t) {
                 if (count >= elements.length) {
                     // !?! mduigou smarter expansion policy needed
-                    Arrays.copyOf(elements, elements.length + DEFAULT_CHUNK);
+                    elements = Arrays.copyOf(elements, elements.length + DEFAULT_CHUNK);
                 }
 
                 elements[count++] = t;
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ToArrayOpTest.java	Tue Aug 14 10:29:46 2012 -0700
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ToArrayOpTest.java	Tue Aug 14 12:27:32 2012 -0700
@@ -26,15 +26,12 @@
 
 import org.testng.annotations.Test;
 
-import java.util.streams.ops.FilterOp;
-import java.util.streams.ops.MapOp;
 import java.util.streams.ops.ToArrayOp;
 import java.util.Arrays;
 import java.util.List;
 
 import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-import static org.openjdk.tests.java.util.LambdaTestHelpers.pEven;
-import static org.openjdk.tests.java.util.LambdaTestHelpers.pOdd;
+
 
 /**
  * ToArrayOpTest
@@ -45,13 +42,13 @@
         ToArrayOp<Integer> op = ToArrayOp.singleton();
         assertCountSum((List<Integer>) (List) Arrays.asList(
                 iteratorToStatefulSink(countTo(0).iterator(), op.sink())), 0, 0);
-        assertCountSum((List<Integer>) (List) Arrays.asList((Integer[])
+        assertCountSum((List<Integer>) (List) Arrays.asList(
                 iteratorToStatefulSink(countTo(10).iterator(), op.sink())), 10, 55);
     }
 
     @Test(dataProvider = "opArrays")
     public void testOps(Integer[] data) {
         ToArrayOp<Integer> op = ToArrayOp.singleton();
-      //  assertConsistentOpBehavior(data, op, null);
+        assertConsistentOpBehavior(data, op);
     }
 }
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/UniqOpTest.java	Tue Aug 14 10:29:46 2012 -0700
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/UniqOpTest.java	Tue Aug 14 12:27:32 2012 -0700
@@ -40,9 +40,8 @@
  */
 public class UniqOpTest extends StreamOpTestCase {
     public void testRawIterator() {
-        assertCountSum(UniqOp.<Integer>singleton().iterator(repeat(10, 0).iterator()), 0 , 0);
-        assertCountSum(UniqOp.<Integer>singleton().iterator(repeat(10, 0).iterator()), 1 , 0);
-        assertCountSum(UniqOp.<Integer>singleton().iterator(repeat(10, 1).iterator()), 1 , 1);
+        assertCountSum(UniqOp.<Integer>singleton().iterator(repeat(0, 10).iterator()), 1 , 0);
+        assertCountSum(UniqOp.<Integer>singleton().iterator(repeat(1, 10).iterator()), 1 , 1);
         assertCountSum(UniqOp.<Integer>singleton().iterator(countTo(0).iterator()), 0, 0);
         assertCountSum(UniqOp.<Integer>singleton().iterator(countTo(10).iterator()), 10, 55);
         assertCountSum(UniqOp.<Integer>singleton().iterator(countTo(10).iterator()), 10, 55);