changeset 6420:68a734033306

Rename directories to correct package names.
author psandoz
date Fri, 16 Nov 2012 10:49:00 +0100
parents a4c10f71e673
children e9b1e2f1094c
files test-ng/tests/org/openjdk/tests/java/util/function/DoubleUnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/function/FunctionsTest.java test-ng/tests/org/openjdk/tests/java/util/function/IntUnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/function/LongUnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/function/PredicatesTest.java test-ng/tests/org/openjdk/tests/java/util/function/UnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/functions/DoubleUnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/functions/FunctionsTest.java test-ng/tests/org/openjdk/tests/java/util/functions/IntUnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/functions/LongUnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/functions/PredicatesTest.java test-ng/tests/org/openjdk/tests/java/util/functions/UnaryOperatorTest.java test-ng/tests/org/openjdk/tests/java/util/stream/CollectionModifyStreamTest.java test-ng/tests/org/openjdk/tests/java/util/stream/OpTestCase.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamIntermediateOpTestScenario.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamOpFlagsTest.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestData.java test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestDataProvider.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ConcatOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/CumulateOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FilterOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FindAnyOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FindFirstOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/FlatMapOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ForEachOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/GroupByOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/InfiniteStreamWithLimitOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/MapOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/MatchOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeBuilderTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/PrimitiveOpsTests.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ReduceByOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ReduceTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/SliceOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/SortedOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/TeeOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/TestFlagExpectedOp.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ToArrayOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/UniqOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/UnorderedStreamTest.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntFilterOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamIntermediateOpTestScenario.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestData.java test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestDataProvider.java test-ng/tests/org/openjdk/tests/java/util/streams/CollectionModifyStreamTest.java test-ng/tests/org/openjdk/tests/java/util/streams/OpTestCase.java test-ng/tests/org/openjdk/tests/java/util/streams/StreamIntermediateOpTestScenario.java test-ng/tests/org/openjdk/tests/java/util/streams/StreamOpFlagsTest.java test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestData.java test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestDataProvider.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/ConcatOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/CumulateOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/FilterOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/FindAnyOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/FindFirstOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/FlagOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/FlatMapOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/ForEachOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/GroupByOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/InfiniteStreamWithLimitOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/IntNodeTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/MapOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/MatchOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeBuilderTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/PrimitiveOpsTests.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceByOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/SliceOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/SortedOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/TeeOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/ops/TestFlagExpectedOp.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 test-ng/tests/org/openjdk/tests/java/util/streams/ops/UnorderedStreamTest.java test-ng/tests/org/openjdk/tests/java/util/streams/primitives/IntFilterOpTest.java test-ng/tests/org/openjdk/tests/java/util/streams/primitives/IntStreamIntermediateOpTestScenario.java test-ng/tests/org/openjdk/tests/java/util/streams/primitives/IntStreamTestData.java test-ng/tests/org/openjdk/tests/java/util/streams/primitives/IntStreamTestDataProvider.java
diffstat 82 files changed, 5270 insertions(+), 5270 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/function/DoubleUnaryOperatorTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.function;
+
+import java.util.function.DoubleUnaryOperator;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ *
+ * @author Jim Gish <jim.gish@oracle.com>
+ */
+public class DoubleUnaryOperatorTest {
+    
+    public DoubleUnaryOperatorTest() {
+    }
+    
+    public void testOperate() {
+        double operand = 2D;
+        DoubleUnaryOperator instance = new DoubleUnaryOperatorImpl();
+        double expResult = 10D;
+        double result = instance.operate(operand);
+        assertEquals(result, expResult, 0.1D /* delta for equality test */ );
+    }
+
+    public class DoubleUnaryOperatorImpl implements DoubleUnaryOperator {
+
+        public double operate(double operand) {
+            // multiply by 5
+            return operand * 5D;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/function/FunctionsTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.java.util.function;
+
+import org.testng.annotations.Test;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.function.Functions;
+
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.fail;
+import static org.testng.AssertJUnit.assertEquals;
+
+/*
+ * Basic test for Functions functional utils
+ * @author  Mike Duigou
+ */
+public class FunctionsTest {
+
+    @Test
+    public void testIdentity() {
+        assertNull(Functions.identity().apply(null));
+        assertEquals(FunctionsTest.class, Functions.identity().apply(FunctionsTest.class));
+    }
+
+    @Test
+    public void testToString() {
+        assertEquals("null", Functions.string().apply(null));
+        assertEquals("1", Functions.string().apply(1));
+        assertEquals("surprise!", Functions.string().apply(new Object() {
+            public String toString() {return "surprise!";}
+        }));
+    }
+
+    @Test
+    public void testConstant() {
+        assertEquals(FunctionsTest.class, Functions.constant(FunctionsTest.class).apply(null));
+        assertEquals(FunctionsTest.class, Functions.constant(FunctionsTest.class).apply("1"));
+    }
+
+    public static class Goomba {
+        public final int value;
+        public Goomba(Integer x) {
+            value = x;
+        }
+    }
+
+    @Test
+    public void testInstantiate() {
+        assertEquals(1, Functions.instantiate(Integer.class, Goomba.class).apply(1).value);
+        assertEquals(2, Functions.instantiate(Integer.class, Goomba.class).apply(2).value);
+    }
+
+    @Test
+    public void testForPredicate() {
+        Function<String, Integer> mapper = Functions.<String, Integer>forPredicate(x -> x != 0, "true", "false");
+
+        assertEquals("false", mapper.apply(0));
+        assertEquals("true", mapper.apply(1));
+    }
+
+    @Test
+    public void testForMap() {
+        Map<Integer, String> truths = new HashMap<>();
+        truths.put(0, "sky");
+        truths.put(1, "ice");
+
+        Function<String, Integer> mapper = Functions.<String, Integer>forMap(truths);
+
+        assertEquals("sky", mapper.apply(0));
+        assertEquals("ice", mapper.apply(1));
+        THROWS(IllegalArgumentException.class, () -> {String result = mapper.apply(999); assert false;});
+    }
+
+    @Test
+    public void testForMapDefault() {
+        Map<Integer, String> truths = new HashMap<>();
+        truths.put(0, "sky");
+        truths.put(1, "ice");
+
+        Function<String, Integer> mapper = Functions.<String, Integer>forMap(truths, "fire");
+
+        assertEquals("sky", mapper.apply(0));
+        assertEquals("ice", mapper.apply(1));
+        assertEquals("fire", mapper.apply(999));
+        assertEquals("fire", mapper.apply(Integer.MAX_VALUE));
+    }
+
+    @Test
+    public void testChain() {
+        Function<Boolean, Integer> first = Functions.<Boolean, Integer>forPredicate(x -> x != 0, true, false);
+        Function<String, Boolean> second = Functions.<String, Boolean>forPredicate(x -> !x, "false", "true");
+        Function<String, Integer> mapper = Functions.chain(first, second);
+
+        assertEquals("false", mapper.apply(0));
+        assertEquals("true", mapper.apply(1));
+    }
+
+    @Test
+    public void testSubstitute() {
+        Function<Integer, Integer> ints = Functions.<Integer>substitute(3, 999);
+        Function<String, String> strings = Functions.<String>substitute("hello", "bonjour");
+        Function<String, String> stringNullIn = Functions.<String>substitute(null, "default");
+        Function<String, String> stringNullOut = Functions.<String>substitute("default", null);
+
+        assertEquals(1, (int) ints.apply(1));
+        assertEquals(999, (int) ints.apply(3));
+        assertEquals("gutentag", strings.apply("gutentag"));
+        assertEquals("bonjour", strings.apply("hello"));
+        assertEquals("gutentag", stringNullIn.apply("gutentag"));
+        assertEquals("default", stringNullIn.apply(null));
+        assertEquals("gutentag", stringNullOut.apply("gutentag"));
+        assertEquals(null, stringNullOut.apply("default"));
+    }
+
+    public interface Fun {void f() throws Throwable;}
+
+    void THROWS(Class<? extends Throwable> k, Fun... fs) {
+        for (Fun f : fs)
+            try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
+            catch (Throwable t) {
+                if (!k.isAssignableFrom(t.getClass()))
+                    throw new UndeclaredThrowableException(t);}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/function/IntUnaryOperatorTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.function;
+
+import java.util.function.IntUnaryOperator;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ *
+ * @author Jim Gish <jim.gish@oracle.com>
+ */
+@Test
+public class IntUnaryOperatorTest {
+    
+    public IntUnaryOperatorTest() {
+    }
+
+    /**
+     * Test of operate method, of class IntUnaryOperator.
+     */
+    public void testOperate() {
+        Integer operand = 3;
+        IntUnaryOperator instance = new IncByTwo();
+        int expResult = 5;
+        int result = instance.operate(operand);
+        assertEquals(result, expResult);
+    }
+
+    public void testOperandInvariance() {
+        Integer operand = 7;
+        IntUnaryOperator op = new IncByTwo();
+        assertEquals( op.operate(operand), op.operate(operand));
+        assertEquals( operand.intValue(), 7 );
+    }
+    
+    public void testUpdateOps() {
+        AtomicInteger atomInt = new AtomicInteger(3);
+        // make sure we the updated value is returned
+        assertEquals( atomInt.updateAndGet(x -> x + 1), 4 );
+        // then the previous value is returned
+        assertEquals( atomInt.getAndUpdate(x -> x + 1), 4 );
+        // finally, verify that the update was successful
+        assertEquals( atomInt.get(), 5 );
+    };
+    
+    public class IncByTwo implements IntUnaryOperator {
+
+        @Override
+        public int operate(int operand) {
+            return operand+2;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/function/LongUnaryOperatorTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.function;
+
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.LongUnaryOperator;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ *
+ * @author Jim Gish <jim.gish@oracle.com>
+ */
+ @Test
+ public class LongUnaryOperatorTest {
+    
+    public LongUnaryOperatorTest() {
+    }
+    
+
+    /**
+     * Test of operate method, of class LongUnaryOperator.
+     */
+    public void testOperate() {
+        long operand = 0L;
+        LongUnaryOperator instance = new LongUnaryOperatorImpl();
+        long expResult = 3L;
+        long result = instance.operate(operand);
+        assertEquals(result, expResult);
+    }
+    
+    public void testUpdateOps() {
+        AtomicLong atomLong = new AtomicLong(3);
+        // make sure we the updated value is returned
+        assertEquals( atomLong.updateAndGet(x -> x + 1), 4 );
+        // then the previous value is returned
+        assertEquals( atomLong.getAndUpdate(x -> x + 1), 4 );
+        // finally, verify that the update was successful
+        assertEquals( atomLong.get(), 5 );
+    };
+    
+    public class LongUnaryOperatorImpl implements LongUnaryOperator {
+
+        public long operate(long operand) {
+            // inc by 3
+            return operand + 3L;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/function/PredicatesTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.openjdk.tests.java.util.function;
+
+import org.testng.annotations.Test;
+
+import java.io.*;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.function.Predicates;
+
+import static org.testng.Assert.assertTrue;
+
+/*
+ * Basic test for Predicates functional utils
+ * @author  Mike Duigou
+ */
+public class PredicatesTest {
+
+    @Test
+    public void testIsNull() {
+        assertTrue(Predicates.isNull().test(null));
+        assertTrue(!Predicates.isNull().test(1));
+        assertTrue(!Predicates.isNull().test("true"));
+        assertTrue(!Predicates.isNull().test(PredicatesTest.class));
+    }
+
+    @Test
+    public void testIsNonNull() {
+        assertTrue(!Predicates.nonNull().test(null));
+        assertTrue(Predicates.nonNull().test(1));
+        assertTrue(Predicates.nonNull().test("true"));
+        assertTrue(Predicates.nonNull().test(PredicatesTest.class));
+    }
+
+    public void testAlwaysFalse() {
+        assertTrue(!Predicates.alwaysFalse().test(null));
+        assertTrue(!Predicates.alwaysFalse().test(1));
+        assertTrue(!Predicates.alwaysFalse().test("true"));
+        assertTrue(!Predicates.alwaysFalse().test(PredicatesTest.class));
+    }
+
+    @Test
+    public void testAlwaysTrue() {
+        assertTrue(Predicates.alwaysTrue().test(null));
+        assertTrue(Predicates.alwaysTrue().test(1));
+        assertTrue(Predicates.alwaysTrue().test("true"));
+        assertTrue(Predicates.alwaysTrue().test(PredicatesTest.class));
+    }
+
+    @Test
+    public void testNegate() {
+        Predicate<Integer> predicate = x->x != 0;
+
+        assertTrue(predicate.test(0) != Predicates.negate(predicate).test(0));
+        assertTrue(predicate.test(1) != Predicates.negate(predicate).test(1));
+    }
+
+    @Test
+    public void testAnd() {
+        Predicate<Integer> first = x->x != 0;
+        Predicate<Integer> second = x->x == 0;
+
+        assertTrue(!Predicates.and(first, first).test(0));
+        assertTrue(Predicates.and(first, first).test(1));
+        assertTrue(!Predicates.and(first, second).test(0));
+        assertTrue(!Predicates.and(first, second).test(1));
+    }
+
+    @Test
+    public void testAndVarArgs() {
+        Predicate<Integer> first = x->x != 0;
+        Predicate<Integer> second = x->x == 0;
+
+        @SuppressWarnings("unchecked")
+        Predicate<Integer> predicates1[] = (Predicate<Integer>[]) new Predicate<?>[]{first, first};
+
+        @SuppressWarnings("unchecked")
+        Predicate<Integer> predicates2[] = (Predicate<Integer>[]) new Predicate<?>[]{first, second};
+
+        //THROWS(NullPointerException.class, () -> { Predicates.and(new Predicate[] {null}); });
+        assertTrue(!Predicates.and(predicates1).test(0));
+        assertTrue(Predicates.and(predicates1).test(1));
+        assertTrue(!Predicates.and(predicates2).test(0));
+        assertTrue(!Predicates.and(predicates2).test(1));
+    }
+
+    @Test
+    public void testOr() {
+        Predicate<Integer> first = x->x != 0;
+        Predicate<Integer> second = x->x == 0;
+
+        assertTrue(!Predicates.or(first, first).test(0));
+        assertTrue(Predicates.or(first, first).test(1));
+        assertTrue(Predicates.or(first, second).test(0));
+        assertTrue(Predicates.or(first, second).test(1));
+    }
+
+
+    @Test
+    public void testOrVarArgs() {
+        Predicate<Integer> first = x->x != 0;
+        Predicate<Integer> second = x->x == 0;
+
+        @SuppressWarnings("unchecked")
+        Predicate<Integer> predicates1[] = (Predicate<Integer>[]) new Predicate<?>[]{first, first};
+
+        @SuppressWarnings("unchecked")
+        Predicate<Integer> predicates2[] = (Predicate<Integer>[]) new Predicate<?>[]{first, second};
+
+        //THROWS(NullPointerException.class, () -> { Predicates.or(new Predicate[] {null}); });
+        assertTrue(!Predicates.or(predicates1).test(0));
+        assertTrue(Predicates.or(predicates1).test(1));
+        assertTrue(Predicates.or(predicates2).test(0));
+        assertTrue(Predicates.or(predicates2).test(1));
+    }
+
+    @Test
+    public void testXor() {
+        Predicate<Integer> first = x->x != 0;
+        Predicate<Integer> second = x->x == 0;
+
+        assertTrue(!Predicates.xor(first, first).test(0));
+        assertTrue(!Predicates.xor(first, first).test(1));
+        assertTrue(Predicates.xor(first, second).test(0));
+        assertTrue(Predicates.xor(first, second).test(1));
+    }
+
+    @Test
+    public void testXorVarArgs() {
+        Predicate<Integer> first = x->x != 0;
+        Predicate<Integer> second = x->x == 0;
+
+        @SuppressWarnings("unchecked")
+        Predicate<Integer> predicates1[] = (Predicate<Integer>[]) new Predicate<?>[]{
+                first, first
+        };
+
+        @SuppressWarnings("unchecked")
+        Predicate<Integer> predicates2[] = (Predicate<Integer>[]) new Predicate<?>[]{
+                first, second
+        };
+
+        boolean onesZero = Predicates.xor(predicates1).test(0);
+        boolean onesOne = Predicates.xor(predicates1).test(1);
+        boolean twosZero = Predicates.xor(predicates2).test(0);
+        boolean twosOne = Predicates.xor(predicates2).test(1);
+
+        assertTrue(!onesZero);
+        assertTrue(!onesOne);
+        assertTrue(twosZero);
+        assertTrue(twosOne);
+    }
+
+    @Test(expectedExceptions = {NullPointerException.class})
+    void testXorNPE() {
+        @SuppressWarnings("unchecked")
+        Predicate<String>[] predicates = (Predicate<String>[]) new Predicate<?>[1];
+        predicates[0] = null;
+        Predicate<String> p = Predicates.xor(predicates);
+        boolean result = p.test("");
+    }
+
+    private interface Fun {
+        void f() throws Throwable;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/function/UnaryOperatorTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.function;
+
+import java.util.function.UnaryOperator;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ *
+ * @author Jim Gish <jim.gish@oracle.com>
+ * @since 1.8
+ */
+@Test
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class UnaryOperatorTest {
+    
+    public UnaryOperatorTest() {
+    }
+
+    /**
+     * Test of operate method, of class UnaryOperator.
+     */
+    public void testOperate() {
+        Integer operand = 3;
+        UnaryOperator<Object> instance = new IncByTwo();
+        Integer expResult = 5;
+        Integer result = (Integer) instance.operate(operand);
+        assertEquals(result, expResult);
+    }
+
+    public class IncByTwo implements UnaryOperator<Object> {
+
+        @Override
+        public Object operate(Object operand) {
+            if ( operand instanceof Number ) {
+                return ((Number)operand).intValue() + 2;
+            } else {
+                return operand;  // can't add to anything but a number
+            }
+        }
+    }
+}
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/DoubleUnaryOperatorTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- * 
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- * 
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.function;
-
-import java.util.function.DoubleUnaryOperator;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- *
- * @author Jim Gish <jim.gish@oracle.com>
- */
-public class DoubleUnaryOperatorTest {
-    
-    public DoubleUnaryOperatorTest() {
-    }
-    
-    public void testOperate() {
-        double operand = 2D;
-        DoubleUnaryOperator instance = new DoubleUnaryOperatorImpl();
-        double expResult = 10D;
-        double result = instance.operate(operand);
-        assertEquals(result, expResult, 0.1D /* delta for equality test */ );
-    }
-
-    public class DoubleUnaryOperatorImpl implements DoubleUnaryOperator {
-
-        public double operate(double operand) {
-            // multiply by 5
-            return operand * 5D;
-        }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/FunctionsTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.openjdk.tests.java.util.function;
-
-import org.testng.annotations.Test;
-
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.function.Functions;
-
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.fail;
-import static org.testng.AssertJUnit.assertEquals;
-
-/*
- * Basic test for Functions functional utils
- * @author  Mike Duigou
- */
-public class FunctionsTest {
-
-    @Test
-    public void testIdentity() {
-        assertNull(Functions.identity().apply(null));
-        assertEquals(FunctionsTest.class, Functions.identity().apply(FunctionsTest.class));
-    }
-
-    @Test
-    public void testToString() {
-        assertEquals("null", Functions.string().apply(null));
-        assertEquals("1", Functions.string().apply(1));
-        assertEquals("surprise!", Functions.string().apply(new Object() {
-            public String toString() {return "surprise!";}
-        }));
-    }
-
-    @Test
-    public void testConstant() {
-        assertEquals(FunctionsTest.class, Functions.constant(FunctionsTest.class).apply(null));
-        assertEquals(FunctionsTest.class, Functions.constant(FunctionsTest.class).apply("1"));
-    }
-
-    public static class Goomba {
-        public final int value;
-        public Goomba(Integer x) {
-            value = x;
-        }
-    }
-
-    @Test
-    public void testInstantiate() {
-        assertEquals(1, Functions.instantiate(Integer.class, Goomba.class).apply(1).value);
-        assertEquals(2, Functions.instantiate(Integer.class, Goomba.class).apply(2).value);
-    }
-
-    @Test
-    public void testForPredicate() {
-        Function<String, Integer> mapper = Functions.<String, Integer>forPredicate(x -> x != 0, "true", "false");
-
-        assertEquals("false", mapper.apply(0));
-        assertEquals("true", mapper.apply(1));
-    }
-
-    @Test
-    public void testForMap() {
-        Map<Integer, String> truths = new HashMap<>();
-        truths.put(0, "sky");
-        truths.put(1, "ice");
-
-        Function<String, Integer> mapper = Functions.<String, Integer>forMap(truths);
-
-        assertEquals("sky", mapper.apply(0));
-        assertEquals("ice", mapper.apply(1));
-        THROWS(IllegalArgumentException.class, () -> {String result = mapper.apply(999); assert false;});
-    }
-
-    @Test
-    public void testForMapDefault() {
-        Map<Integer, String> truths = new HashMap<>();
-        truths.put(0, "sky");
-        truths.put(1, "ice");
-
-        Function<String, Integer> mapper = Functions.<String, Integer>forMap(truths, "fire");
-
-        assertEquals("sky", mapper.apply(0));
-        assertEquals("ice", mapper.apply(1));
-        assertEquals("fire", mapper.apply(999));
-        assertEquals("fire", mapper.apply(Integer.MAX_VALUE));
-    }
-
-    @Test
-    public void testChain() {
-        Function<Boolean, Integer> first = Functions.<Boolean, Integer>forPredicate(x -> x != 0, true, false);
-        Function<String, Boolean> second = Functions.<String, Boolean>forPredicate(x -> !x, "false", "true");
-        Function<String, Integer> mapper = Functions.chain(first, second);
-
-        assertEquals("false", mapper.apply(0));
-        assertEquals("true", mapper.apply(1));
-    }
-
-    @Test
-    public void testSubstitute() {
-        Function<Integer, Integer> ints = Functions.<Integer>substitute(3, 999);
-        Function<String, String> strings = Functions.<String>substitute("hello", "bonjour");
-        Function<String, String> stringNullIn = Functions.<String>substitute(null, "default");
-        Function<String, String> stringNullOut = Functions.<String>substitute("default", null);
-
-        assertEquals(1, (int) ints.apply(1));
-        assertEquals(999, (int) ints.apply(3));
-        assertEquals("gutentag", strings.apply("gutentag"));
-        assertEquals("bonjour", strings.apply("hello"));
-        assertEquals("gutentag", stringNullIn.apply("gutentag"));
-        assertEquals("default", stringNullIn.apply(null));
-        assertEquals("gutentag", stringNullOut.apply("gutentag"));
-        assertEquals(null, stringNullOut.apply("default"));
-    }
-
-    public interface Fun {void f() throws Throwable;}
-
-    void THROWS(Class<? extends Throwable> k, Fun... fs) {
-        for (Fun f : fs)
-            try { f.f(); fail("Expected " + k.getName() + " not thrown"); }
-            catch (Throwable t) {
-                if (!k.isAssignableFrom(t.getClass()))
-                    throw new UndeclaredThrowableException(t);}
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/IntUnaryOperatorTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- * 
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- * 
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.function;
-
-import java.util.function.IntUnaryOperator;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- *
- * @author Jim Gish <jim.gish@oracle.com>
- */
-@Test
-public class IntUnaryOperatorTest {
-    
-    public IntUnaryOperatorTest() {
-    }
-
-    /**
-     * Test of operate method, of class IntUnaryOperator.
-     */
-    public void testOperate() {
-        Integer operand = 3;
-        IntUnaryOperator instance = new IncByTwo();
-        int expResult = 5;
-        int result = instance.operate(operand);
-        assertEquals(result, expResult);
-    }
-
-    public void testOperandInvariance() {
-        Integer operand = 7;
-        IntUnaryOperator op = new IncByTwo();
-        assertEquals( op.operate(operand), op.operate(operand));
-        assertEquals( operand.intValue(), 7 );
-    }
-    
-    public void testUpdateOps() {
-        AtomicInteger atomInt = new AtomicInteger(3);
-        // make sure we the updated value is returned
-        assertEquals( atomInt.updateAndGet(x -> x + 1), 4 );
-        // then the previous value is returned
-        assertEquals( atomInt.getAndUpdate(x -> x + 1), 4 );
-        // finally, verify that the update was successful
-        assertEquals( atomInt.get(), 5 );
-    };
-    
-    public class IncByTwo implements IntUnaryOperator {
-
-        @Override
-        public int operate(int operand) {
-            return operand+2;
-        }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/LongUnaryOperatorTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- * 
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- * 
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.function;
-
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.function.LongUnaryOperator;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- *
- * @author Jim Gish <jim.gish@oracle.com>
- */
- @Test
- public class LongUnaryOperatorTest {
-    
-    public LongUnaryOperatorTest() {
-    }
-    
-
-    /**
-     * Test of operate method, of class LongUnaryOperator.
-     */
-    public void testOperate() {
-        long operand = 0L;
-        LongUnaryOperator instance = new LongUnaryOperatorImpl();
-        long expResult = 3L;
-        long result = instance.operate(operand);
-        assertEquals(result, expResult);
-    }
-    
-    public void testUpdateOps() {
-        AtomicLong atomLong = new AtomicLong(3);
-        // make sure we the updated value is returned
-        assertEquals( atomLong.updateAndGet(x -> x + 1), 4 );
-        // then the previous value is returned
-        assertEquals( atomLong.getAndUpdate(x -> x + 1), 4 );
-        // finally, verify that the update was successful
-        assertEquals( atomLong.get(), 5 );
-    };
-    
-    public class LongUnaryOperatorImpl implements LongUnaryOperator {
-
-        public long operate(long operand) {
-            // inc by 3
-            return operand + 3L;
-        }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/PredicatesTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package org.openjdk.tests.java.util.function;
-
-import org.testng.annotations.Test;
-
-import java.io.*;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-import java.util.function.Predicate;
-import java.util.function.Predicates;
-
-import static org.testng.Assert.assertTrue;
-
-/*
- * Basic test for Predicates functional utils
- * @author  Mike Duigou
- */
-public class PredicatesTest {
-
-    @Test
-    public void testIsNull() {
-        assertTrue(Predicates.isNull().test(null));
-        assertTrue(!Predicates.isNull().test(1));
-        assertTrue(!Predicates.isNull().test("true"));
-        assertTrue(!Predicates.isNull().test(PredicatesTest.class));
-    }
-
-    @Test
-    public void testIsNonNull() {
-        assertTrue(!Predicates.nonNull().test(null));
-        assertTrue(Predicates.nonNull().test(1));
-        assertTrue(Predicates.nonNull().test("true"));
-        assertTrue(Predicates.nonNull().test(PredicatesTest.class));
-    }
-
-    public void testAlwaysFalse() {
-        assertTrue(!Predicates.alwaysFalse().test(null));
-        assertTrue(!Predicates.alwaysFalse().test(1));
-        assertTrue(!Predicates.alwaysFalse().test("true"));
-        assertTrue(!Predicates.alwaysFalse().test(PredicatesTest.class));
-    }
-
-    @Test
-    public void testAlwaysTrue() {
-        assertTrue(Predicates.alwaysTrue().test(null));
-        assertTrue(Predicates.alwaysTrue().test(1));
-        assertTrue(Predicates.alwaysTrue().test("true"));
-        assertTrue(Predicates.alwaysTrue().test(PredicatesTest.class));
-    }
-
-    @Test
-    public void testNegate() {
-        Predicate<Integer> predicate = x->x != 0;
-
-        assertTrue(predicate.test(0) != Predicates.negate(predicate).test(0));
-        assertTrue(predicate.test(1) != Predicates.negate(predicate).test(1));
-    }
-
-    @Test
-    public void testAnd() {
-        Predicate<Integer> first = x->x != 0;
-        Predicate<Integer> second = x->x == 0;
-
-        assertTrue(!Predicates.and(first, first).test(0));
-        assertTrue(Predicates.and(first, first).test(1));
-        assertTrue(!Predicates.and(first, second).test(0));
-        assertTrue(!Predicates.and(first, second).test(1));
-    }
-
-    @Test
-    public void testAndVarArgs() {
-        Predicate<Integer> first = x->x != 0;
-        Predicate<Integer> second = x->x == 0;
-
-        @SuppressWarnings("unchecked")
-        Predicate<Integer> predicates1[] = (Predicate<Integer>[]) new Predicate<?>[]{first, first};
-
-        @SuppressWarnings("unchecked")
-        Predicate<Integer> predicates2[] = (Predicate<Integer>[]) new Predicate<?>[]{first, second};
-
-        //THROWS(NullPointerException.class, () -> { Predicates.and(new Predicate[] {null}); });
-        assertTrue(!Predicates.and(predicates1).test(0));
-        assertTrue(Predicates.and(predicates1).test(1));
-        assertTrue(!Predicates.and(predicates2).test(0));
-        assertTrue(!Predicates.and(predicates2).test(1));
-    }
-
-    @Test
-    public void testOr() {
-        Predicate<Integer> first = x->x != 0;
-        Predicate<Integer> second = x->x == 0;
-
-        assertTrue(!Predicates.or(first, first).test(0));
-        assertTrue(Predicates.or(first, first).test(1));
-        assertTrue(Predicates.or(first, second).test(0));
-        assertTrue(Predicates.or(first, second).test(1));
-    }
-
-
-    @Test
-    public void testOrVarArgs() {
-        Predicate<Integer> first = x->x != 0;
-        Predicate<Integer> second = x->x == 0;
-
-        @SuppressWarnings("unchecked")
-        Predicate<Integer> predicates1[] = (Predicate<Integer>[]) new Predicate<?>[]{first, first};
-
-        @SuppressWarnings("unchecked")
-        Predicate<Integer> predicates2[] = (Predicate<Integer>[]) new Predicate<?>[]{first, second};
-
-        //THROWS(NullPointerException.class, () -> { Predicates.or(new Predicate[] {null}); });
-        assertTrue(!Predicates.or(predicates1).test(0));
-        assertTrue(Predicates.or(predicates1).test(1));
-        assertTrue(Predicates.or(predicates2).test(0));
-        assertTrue(Predicates.or(predicates2).test(1));
-    }
-
-    @Test
-    public void testXor() {
-        Predicate<Integer> first = x->x != 0;
-        Predicate<Integer> second = x->x == 0;
-
-        assertTrue(!Predicates.xor(first, first).test(0));
-        assertTrue(!Predicates.xor(first, first).test(1));
-        assertTrue(Predicates.xor(first, second).test(0));
-        assertTrue(Predicates.xor(first, second).test(1));
-    }
-
-    @Test
-    public void testXorVarArgs() {
-        Predicate<Integer> first = x->x != 0;
-        Predicate<Integer> second = x->x == 0;
-
-        @SuppressWarnings("unchecked")
-        Predicate<Integer> predicates1[] = (Predicate<Integer>[]) new Predicate<?>[]{
-                first, first
-        };
-
-        @SuppressWarnings("unchecked")
-        Predicate<Integer> predicates2[] = (Predicate<Integer>[]) new Predicate<?>[]{
-                first, second
-        };
-
-        boolean onesZero = Predicates.xor(predicates1).test(0);
-        boolean onesOne = Predicates.xor(predicates1).test(1);
-        boolean twosZero = Predicates.xor(predicates2).test(0);
-        boolean twosOne = Predicates.xor(predicates2).test(1);
-
-        assertTrue(!onesZero);
-        assertTrue(!onesOne);
-        assertTrue(twosZero);
-        assertTrue(twosOne);
-    }
-
-    @Test(expectedExceptions = {NullPointerException.class})
-    void testXorNPE() {
-        @SuppressWarnings("unchecked")
-        Predicate<String>[] predicates = (Predicate<String>[]) new Predicate<?>[1];
-        predicates[0] = null;
-        Predicate<String> p = Predicates.xor(predicates);
-        boolean result = p.test("");
-    }
-
-    private interface Fun {
-        void f() throws Throwable;
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/functions/UnaryOperatorTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- * 
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- * 
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.function;
-
-import java.util.function.UnaryOperator;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- *
- * @author Jim Gish <jim.gish@oracle.com>
- * @since 1.8
- */
-@Test
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class UnaryOperatorTest {
-    
-    public UnaryOperatorTest() {
-    }
-
-    /**
-     * Test of operate method, of class UnaryOperator.
-     */
-    public void testOperate() {
-        Integer operand = 3;
-        UnaryOperator<Object> instance = new IncByTwo();
-        Integer expResult = 5;
-        Integer result = (Integer) instance.operate(operand);
-        assertEquals(result, expResult);
-    }
-
-    public class IncByTwo implements UnaryOperator<Object> {
-
-        @Override
-        public Object operate(Object operand) {
-            if ( operand instanceof Number ) {
-                return ((Number)operand).intValue() + 2;
-            } else {
-                return operand;  // can't add to anything but a number
-            }
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/CollectionModifyStreamTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream;
+
+import org.openjdk.tests.java.util.LambdaTestHelpers;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.*;
+import java.util.stream.Stream;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+@Test
+public class CollectionModifyStreamTest {
+
+    @DataProvider(name = "collections")
+    public Object[][] createCollections() {
+        List<Integer> content = LambdaTestHelpers.countTo(10);
+
+        List<Collection<Integer>> collections = new ArrayList<>();
+        collections.add(new ArrayList<>(content));
+        collections.add(new LinkedList<>(content));
+        collections.add(new Vector<>(content));
+
+        collections.add(new HashSet<>(content));
+        collections.add(new LinkedHashSet<>(content));
+        collections.add(new TreeSet<>(content));
+
+        Stack<Integer> stack = new Stack<>();
+        stack.addAll(content);
+        collections.add(stack);
+        collections.add(new PriorityQueue<>(content));
+        collections.add(new ArrayDeque<>(content));
+
+        // Concurrent collections
+
+        Object[][] params = new Object[collections.size()][];
+        for (int i = 0; i < collections.size(); i++) {
+            params[i] = new Object[]{collections.get(i).getClass().getName(), collections.get(i)};
+        }
+
+        return params;
+    }
+
+    @Test(dataProvider = "collections")
+    public void testSizeRemove(String name, Collection<Integer> c) {
+        assertTrue(c.remove((Object) Integer.valueOf(1)));
+        Stream<Integer> s = c.stream();
+        assertTrue(c.remove((Object) Integer.valueOf(2)));
+        Object[] result = s.toArray();
+        assertEquals(result.length, c.size());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/OpTestCase.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream;
+
+import org.openjdk.tests.java.util.LambdaTestHelpers;
+import org.openjdk.tests.java.util.stream.primitive.IntStreamIntermediateOpTestScenario;
+import org.testng.Assert;
+import org.testng.ITestContext;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.*;
+import java.util.function.BiPredicate;
+import java.util.function.Block;
+import java.util.function.Supplier;
+import java.util.function.Function;
+import java.util.stream.*;
+import java.util.stream.op.*;
+import java.util.stream.primitive.IntStream;
+
+/**
+ * StreamOpTestCase
+ *
+ * @author Brian Goetz
+ */
+@Test
+public abstract class OpTestCase extends Assert {
+
+    @SuppressWarnings("rawtypes")
+    private final Map<Class, Set<? extends IntermediateOpTestScenario>> testScenarios;
+
+    protected OpTestCase() {
+        // @@@ This only needs to be done once, consider using injection or an attribute on ITestContext
+        testScenarios = new HashMap<>();
+        testScenarios.put(Stream.class, Collections.unmodifiableSet(EnumSet.allOf(StreamIntermediateOpTestScenario.class)));
+        testScenarios.put(IntStream.class, Collections.unmodifiableSet(EnumSet.allOf(IntStreamIntermediateOpTestScenario.class)));
+    }
+
+    // Exercise intermediate operations
+
+    @SuppressWarnings("rawtypes")
+    public interface IntermediateOpTestScenario {
+        StreamShape getShape();
+
+        boolean isParallel();
+
+        abstract <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> void run(TestData<T, S_IN> data, Block<U> b, Function<S_OUT, S_IN> m);
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T, U, S_IN extends BaseStream<T>> Node<U> exerciseOps(TestData<T, S_IN> data, IntermediateOp... ops) {
+        return (Node<U>) withData(data).
+                using(ops).
+                exercise();
+    }
+
+    public <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> Node<U> exerciseOps(TestData<T, S_IN> data, Function<S_OUT, S_IN> m) {
+        return withData(data).
+                using(m).
+                exercise();
+    }
+
+    public <T, U, S_OUT extends BaseStream<U>> Node<U> exerciseOps(Collection<T> data, Function<S_OUT, Stream<T>> m) {
+        return withData(new StreamTestData.CollectionData<>("Collection of type " + data.getClass().getName(), data)).
+                using(m).
+                exercise();
+    }
+
+    public <T, U, S_OUT extends BaseStream<U>, I extends Iterable<U> & Sized> Node<U> exerciseOps(Collection<T> data, Function<S_OUT, Stream<T>> m, I expected) {
+        return withData(new StreamTestData.CollectionData<>("Collection of type " + data.getClass().getName(), data)).
+                using(m).
+                expectedResult(expected).
+                exercise();
+    }
+
+    public <T, S_IN extends BaseStream<T>> IntermediateOpDataBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
+        Objects.requireNonNull(data);
+        return new IntermediateOpDataBuilder<>(data);
+    }
+
+    @SuppressWarnings("rawtypes")
+    public class IntermediateOpDataBuilder<T, S_IN extends BaseStream<T>> {
+        final TestData<T, S_IN> data;
+
+        private IntermediateOpDataBuilder(TestData<T, S_IN> data) {
+            this.data = Objects.requireNonNull(data);
+        }
+
+        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> using(IntermediateOp... ops) {
+            return usingOpsFactory(() -> ops);
+        }
+
+        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> usingOpFactory(Supplier<IntermediateOp> fop) {
+            return usingOpsFactory(() -> new IntermediateOp[] { fop.get() });
+        }
+
+        @SuppressWarnings("unchecked")
+        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> usingOpsFactory(Supplier<IntermediateOp[]> fops) {
+            return using((S_IN s) -> (S_OUT) chain((AbstractPipeline<?, T>)s, fops.get()));
+        }
+
+        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> using(Function<S_OUT, S_IN> m) {
+            return new IntermediateOpTestBuilder<>(data, m);
+        }
+
+    }
+
+    @SuppressWarnings("rawtypes")
+    public class IntermediateOpTestBuilder<T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> {
+        final TestData<T, S_IN> data;
+
+        final Function<S_OUT, S_IN> m;
+
+        final StreamShape shape;
+
+        Set<IntermediateOpTestScenario> testSet = new HashSet<>();
+
+        Node<U> refResult;
+
+        @SuppressWarnings("unchecked")
+        Block<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
+
+        @SuppressWarnings("unchecked")
+        Block<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
+
+        BiPredicate<Iterable<U>, Iterable<U>> sequentialEqualator = Objects::equals;
+
+        BiPredicate<Iterable<U>, Iterable<U>> parallelEqualator = Objects::equals;
+
+        private IntermediateOpTestBuilder(TestData<T, S_IN> data, Function<S_OUT, S_IN> m) {
+            this.data = data;
+
+            this.m = Objects.requireNonNull(m);
+
+            this.shape = ((AbstractPipeline<?, U>) m.apply(data.stream())).getOutputShape();
+
+            // Have to initiate from the output shape of the last stream
+            // This means the stream mapper is required first rather than last
+            testSet.addAll(testScenarios.get(shape.getStreamType()));
+        }
+
+        public BiPredicate<Iterable<U>, Iterable<U>> getEqualator(IntermediateOpTestScenario t) {
+            return t.isParallel() ? parallelEqualator : sequentialEqualator;
+        }
+
+        //
+
+        @SuppressWarnings("unchecked")
+        public <I extends Iterable<U> & Sized> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
+            NodeBuilder<U> resultBuilder = shape.makeNodeBuilder(expectedResult.size());
+            resultBuilder.begin(expectedResult.size());
+            expectedResult.forEach(resultBuilder);
+            resultBuilder.end();
+            this.refResult = resultBuilder.build();
+            return this;
+        }
+
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> before(Block<TestData<T, S_IN>> before) {
+            this.before = Objects.requireNonNull(before);
+            return this;
+        }
+
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> after(Block<TestData<T, S_IN>> after) {
+            this.after = Objects.requireNonNull(after);
+            return this;
+        }
+
+        @SuppressWarnings("unchecked")
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> without(IntermediateOpTestScenario... tests) {
+            return without(Arrays.asList(tests));
+        }
+
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> without(Collection<? extends IntermediateOpTestScenario> tests) {
+            for (IntermediateOpTestScenario ts : tests) {
+                if (ts.getShape().getStreamType() == shape.getStreamType()) {
+                    testSet.remove(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        @SuppressWarnings("unchecked")
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> with(IntermediateOpTestScenario... tests) {
+            return with(Arrays.asList(tests));
+        }
+
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> with(Collection<? extends IntermediateOpTestScenario> tests) {
+            testSet = new HashSet<>();
+
+            for (IntermediateOpTestScenario ts : tests) {
+                if (ts.getShape().getStreamType() == shape.getStreamType()) {
+                    testSet.add(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> sequentialEqualator(BiPredicate<Iterable<U>, Iterable<U>> equalator) {
+            this.sequentialEqualator = equalator;
+            return this;
+        }
+
+        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> parallelEqualator(BiPredicate<Iterable<U>, Iterable<U>> equalator) {
+            this.parallelEqualator = equalator;
+            return this;
+        }
+
+        // Build method
+
+        public Node<U> exercise() {
+            return exerciseOps(this);
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    protected static <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> Node<U> exerciseOps(IntermediateOpTestBuilder<T, U, S_IN, S_OUT> b) {
+        Node<U> refResult;
+        if (b.refResult != null) {
+            refResult = b.refResult;
+        } else {
+            // Induce the reference result
+            b.before.apply(b.data);
+            S_OUT sOut = b.m.apply(b.data.stream());
+            refResult = ((AbstractPipeline<?, U>) sOut).collectOutput().flatten();
+            b.after.apply(b.data);
+        }
+
+        for (IntermediateOpTestScenario test : b.testSet) {
+            b.before.apply(b.data);
+
+            NodeBuilder<U> resultBuilder = b.shape.makeNodeBuilder(-1);
+            resultBuilder.begin(-1);
+            test.run(b.data, resultBuilder, b.m);
+            resultBuilder.end();
+            Node<U> result = resultBuilder.build();
+
+            assertTrue(b.getEqualator(test).test(result, refResult),
+                       String.format("%s %s: %s != %s", b.data.toString(), test, refResult, result));
+
+            b.after.apply(b.data);
+        }
+
+        return refResult;
+    }
+
+    // Exercise terminal operations
+
+    @SuppressWarnings("rawtypes")
+    protected <T, U, S_IN extends BaseStream<T>> U exerciseOps(TestData<T, S_IN> data, TerminalOp<T, U> terminal) {
+        return exerciseOps(data, terminal, new IntermediateOp[0]);
+    }
+
+    @SuppressWarnings("rawtypes")
+    protected <T, U, S_IN extends BaseStream<T>> U exerciseOps(TestData<T, S_IN> data, TerminalOp<T, U> terminal, IntermediateOp... ops) {
+        return exerciseOps(data, (u, v) -> Objects.equals(u,v), terminal, ops);
+    }
+
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    protected static <T, U, S_IN extends BaseStream<T>> U exerciseOps(TestData<T, S_IN> data,
+                                          BiPredicate<U, U> equalator,
+                                          TerminalOp<T, U> terminalOp,
+                                          IntermediateOp... ops) {
+
+        // Sequentially collect the output that will be input to the terminal op
+        Node<T> node = (Node<T>) data.seq(ops).collectOutput().flatten();
+        U refResult = chain(terminalOp.inputShape().stream(node),
+                            terminalOp);
+
+        // Single sequential using pull
+        {
+            // @@@ Using specific stream implementation
+            AbstractPipeline<?, T> source = terminalOp.inputShape().stream(node);
+            // Force pull by requesting iterator
+            // @@@ seems fragile is there a better way?
+            source.iterator();
+            U result = source.pipeline(terminalOp);
+            assertTrue(equalator.test(refResult, result), String.format("Single sequential pull: %s != %s", refResult, result));
+        }
+
+        // Single parallel
+        {
+            // @@@ Using specific stream implementation
+            AbstractPipeline<?, T> ap = terminalOp.inputShape().parallel(node);
+            U result = chain(ap, terminalOp);
+            assertTrue(equalator.test(refResult, result), String.format("Single parallel: %s != %s", refResult, result));
+        }
+
+        // All sequential
+        // This may push or pull depending on the terminal op implementation
+        {
+            U result = data.seq(terminalOp, ops);
+            assertTrue(equalator.test(refResult, result), String.format("All sequential: %s != %s", refResult, result));
+        }
+
+        // All sequential using pull
+        {
+            AbstractPipeline<?, T> ap = (AbstractPipeline<?, T>)data.seq(ops);
+            // Force pull by requesting iterator
+            // @@@ seems fragile is there a better way?
+            ap.iterator();
+            U result = ap.pipeline(terminalOp);
+            assertTrue(equalator.test(refResult, result), String.format("All sequential pull: %s != %s", refResult, result));
+        }
+
+        // All parallel
+        {
+            U resultPar = data.par(terminalOp, ops);
+            assertTrue(equalator.test(refResult, resultPar), String.format("All parallel: %s != %s", refResult, resultPar));
+        }
+
+        // All parallel using pull
+        {
+            AbstractPipeline<?, T> ap = (AbstractPipeline<?, T>)data.par(ops);
+            // Force pull by requesting iterator
+            // @@@ seems fragile is there a better way?
+            ap.iterator();
+            U result = ap.pipeline(terminalOp);
+            assertTrue(equalator.test(refResult, result), String.format("All parallel pull: %s != %s", refResult, result));
+        }
+
+        return refResult;
+    }
+
+    //
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static <T> AbstractPipeline<?, T> chain(AbstractPipeline upstream, IntermediateOp<?, T> op) {
+        return upstream.chain(op);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static <U> U chain(AbstractPipeline pipe, TerminalOp<?, U> op) {
+        return (U) pipe.pipeline(op);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static AbstractPipeline<?, ?> chain(AbstractPipeline pipe, IntermediateOp... ops) {
+        for (IntermediateOp op : ops)
+            pipe = chain(pipe, op);
+        return pipe;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static <U> U chain(AbstractPipeline pipe, TerminalOp<?, U> terminal, IntermediateOp... ops) {
+        return chain(chain(pipe, ops), terminal);
+    }
+
+    // Test data
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static interface TestData<T, S extends BaseStream<T>> extends Iterable<T>, Streamable<S>, Sized {
+
+        // @@@ This is not used, should it be removed?
+        Spliterator<T> spliterator();
+
+        //
+
+        StreamShape getShape();
+
+        default <A extends Collection<? super T>> A into(A target) {
+            Iterator<T> iterator = iterator();
+            while (iterator.hasNext())
+                target.add(iterator.next());
+            return target;
+        }
+
+        // Streamable
+
+        @Override
+        S stream();
+
+        @Override
+        S parallel();
+
+        // Source
+
+        @SuppressWarnings({ "rawtypes", "unchecked" })
+        default AbstractPipeline<?, T> seq() {
+            return (AbstractPipeline<?, T>) stream();
+        }
+
+        @SuppressWarnings({ "rawtypes", "unchecked" })
+        default AbstractPipeline<?, T> par() {
+            return (AbstractPipeline<?, T>) stream();
+        }
+
+        // Intermediate
+
+        default <U> AbstractPipeline<?, U> seq(IntermediateOp<T, U> op) {
+            return chain(seq(), op);
+        }
+
+        default <U> AbstractPipeline<?, U> par(IntermediateOp<T, U> op) {
+            return chain(par(), op);
+        }
+
+        default AbstractPipeline<?, ?> seq(IntermediateOp... ops) {
+            return chain(seq(), ops);
+        }
+
+        default AbstractPipeline<?, ?> par(IntermediateOp... ops) {
+            return chain(par(), ops);
+        }
+
+        // Terminal
+
+        default <U> U seq(TerminalOp<T, U> op)  {
+            return chain(seq(), op);
+        }
+
+        default <U> U par(TerminalOp<T, U> op)  {
+            return chain(par(), op);
+        }
+
+        default <U> U seq(TerminalOp<?, U> terminal, IntermediateOp... ops) {
+            return chain(seq(), terminal, ops);
+        }
+
+        default <U> U par(TerminalOp<?, U> terminal, IntermediateOp... ops) {
+            return chain(par(), terminal, ops);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamIntermediateOpTestScenario.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.function.Block;
+import java.util.function.Function;
+import java.util.stream.*;
+import java.util.stream.op.FlagDeclaringOp;
+import java.util.stream.op.IntermediateOp;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum StreamIntermediateOpTestScenario implements OpTestCase.IntermediateOpTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            m.apply(data.stream()).forEach(b);
+        }
+    },
+
+    // Wrap as stream and into a list
+    STREAM_INTO(false) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            for (U t : m.apply(data.stream()).into(new ArrayList<U>())) {
+                b.apply(t);
+            }
+        }
+    },
+
+    // Wrap as stream and into a list
+    STREAM_TO_ARRAY(false) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            for (Object t : m.apply(data.stream()).toArray()) {
+                b.apply((U) t);
+            }
+        }
+    },
+
+    // Wrap as stream, and iterate in pull mode
+    STREAM_ITERATOR(false) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            for (Iterator<U> seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+                b.apply(seqIter.next());
+        }
+    },
+
+    // Wrap as stream, and iterate in mixed mode
+    STREAM_MIXED(false) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            Stream<U> stream = m.apply(data.stream());
+            Iterator<U> iter = stream.iterator();
+            if (iter.hasNext())
+                b.apply(iter.next());
+            stream.forEach(b);
+        }
+    },
+
+    // Wrap as two connected streams, request iterator for the upstream, and do forEach on the downstream
+    STREAM_MIXED_ITERATOR_FOR_EACH(false) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            AbstractPipeline<T, T> pipe1 = data.seq(new NoOp(data.getShape()));
+            Stream<U> pipe2 = m.apply((S_IN) pipe1);
+
+            pipe1.iterator();
+            pipe2.forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + sequential
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            m.apply(data.parallel()).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + toArray
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            for (Object t : m.apply(data.parallel()).toArray())
+                b.apply((U) t);
+        }
+    },
+
+    // Wrap as parallel stream + toArray and clear SIZED flag
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            AbstractPipeline<?, ?> pipe1 = data.par(new FlagDeclaringOp(StreamOpFlags.NOT_SIZED) {
+                @Override
+                public StreamShape outputShape() {
+                    return data.getShape();
+                }
+
+                @Override
+                public StreamShape inputShape() {
+                    return data.getShape();
+                }
+            });
+            Stream<U> pipe2 = m.apply((S_IN) pipe1);
+
+            for (Object t : pipe2.toArray())
+                b.apply((U) t);
+        }
+    },
+
+    // Wrap as parallel stream + into
+    PAR_STREAM_SEQUENTIAL_INTO(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            ArrayList<U> list = m.apply(data.parallel()).sequential().into(new ArrayList<U>());
+            for (U u : list)
+                b.apply(u);
+        }
+    },
+
+    // Wrap as parallel stream, and iterate in mixed mode
+    PAR_STREAM_ITERATOR_TO_ARRAY_MIXED(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            Stream<U> stream = m.apply(data.parallel());
+            Iterator<U> iter = stream.iterator();
+            if (iter.hasNext())
+                b.apply(iter.next());
+            for (Object t : stream.toArray())
+                b.apply((U) t);
+        }
+    },
+
+    // Wrap as two connected streams, request iterator for the upstream, and do forEach on the downstream
+    PAR_STREAM_MIXED_ITERATOR_TO_ARRAY(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            AbstractPipeline<T, T> pipe1 = data.seq(new NoOp(data.getShape()));
+            Stream<U> pipe2 = m.apply((S_IN) pipe1);
+
+            pipe1.iterator();
+            for (Object t : pipe2.toArray())
+                b.apply((U) t);
+        }
+    },
+
+    // Wrap as parallel stream, and iterate in mixed mode
+    PAR_STREAM_SEQUENTIAL_MIXED(true) {
+        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
+            Stream<U> stream = m.apply(data.parallel());
+            Iterator<U> iter = stream.iterator();
+            if (iter.hasNext())
+                b.apply(iter.next());
+            stream.sequential().forEach(b);
+        }
+    },
+
+    // More ways to iterate the PSS: iterate result of op
+    // Extends testing to test whether computation happens in- or out-of-thread
+    ;
+
+    private static class NoOp<T> implements IntermediateOp<T, T> {
+
+        private final StreamShape shape;
+
+        private NoOp(StreamShape shape) {
+            this.shape = shape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return shape;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return shape;
+        }
+
+        @Override
+        public Iterator<T> wrapIterator(int flags, Iterator<T> in) {
+            return in;
+        }
+
+        @Override
+        public Sink<T> wrapSink(int flags, Sink<T> sink) {
+            return sink;
+        }
+    }
+
+    private boolean isParallel;
+
+    StreamIntermediateOpTestScenario(boolean isParallel) {
+        this.isParallel = isParallel;
+    }
+
+    public StreamShape getShape() {
+        return StreamShapeFactory.REFERENCE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> void run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<S_OUT, S_IN> m) {
+        _run(data, b, (Function<Stream<U>, S_IN>) m);
+    }
+
+    abstract <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamOpFlagsTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream;
+
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.StreamOpFlags;
+
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+@Test
+public class StreamOpFlagsTest {
+
+    public void test() {
+        int sourceFlags = StreamOpFlags.IS_SIZED | StreamOpFlags.IS_DISTINCT;
+
+        List<Integer> ops = Arrays.asList(StreamOpFlags.NOT_SIZED, StreamOpFlags.IS_ORDERED | StreamOpFlags.IS_SORTED);
+
+        int opsFlags = StreamOpFlags.INITIAL_OPS_VALUE;
+        for (int opFlags : ops) {
+            opsFlags = StreamOpFlags.combineOpFlags(opFlags, opsFlags);
+        }
+        int flags = StreamOpFlags.combineStreamFlags(sourceFlags, opsFlags);
+
+        assertFalse(StreamOpFlags.SIZED.isKnown(flags));
+        assertTrue(StreamOpFlags.DISTINCT.isKnown(flags));
+        assertTrue(StreamOpFlags.SORTED.isKnown(flags));
+        assertTrue(StreamOpFlags.ORDERED.isKnown(flags));
+
+        assertFalse(StreamOpFlags.SIZED.isKnownOnOpFlags(flags));
+        assertTrue(StreamOpFlags.DISTINCT.isKnownOnOpFlags(flags));
+        assertTrue(StreamOpFlags.SORTED.isKnownOnOpFlags(flags));
+        assertTrue(StreamOpFlags.ORDERED.isKnownOnOpFlags(flags));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestData.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,121 @@
+package org.openjdk.tests.java.util.stream;/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.stream.*;
+
+public abstract class StreamTestData<T> implements OpTestCase.TestData<T, Stream<T>> {
+
+    @Override
+    @SuppressWarnings("rawtypes")
+    public StreamShape getShape() {
+        return StreamShapeFactory.REFERENCE;
+    }
+
+    public static class ArrayData<T> extends StreamTestData<T> {
+        private final String name;
+        private final T[] array;
+
+        public ArrayData(String name, T[] array) {
+            this.name = name;
+            this.array = array;
+        }
+
+        @Override
+        public Stream<T> stream() {
+            return Arrays.stream(array);
+        }
+
+        @Override
+        public Stream<T> parallel() {
+            return Arrays.parallel(array);
+        }
+
+        @Override
+        public Iterator<T> iterator() {
+            return Arrays.iterator(array);
+        }
+
+        @Override
+        public Spliterator<T> spliterator() {
+            return Arrays.spliterator(array);
+        }
+
+        @Override
+        public int size() {
+            return array.length;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+    public static class CollectionData<T> extends StreamTestData<T> {
+        protected final String name;
+        protected final Collection<T> collection;
+
+        public CollectionData(String name, Collection<T> collection) {
+            this.name = name;
+            this.collection = collection;
+        }
+
+        @Override
+        public Stream<T> stream() {
+            return collection.stream();
+        }
+
+        @Override
+        public Stream<T> parallel() {
+            return collection.parallel();
+        }
+
+        @Override
+        public Iterator<T> iterator() {
+            return collection.iterator();
+        }
+
+        @Override
+        @SuppressWarnings({ "rawtypes", "unchecked" })
+        public Spliterator<T> spliterator() {
+            // @@@ FIXME!
+            return Arrays.spliterator((T[]) collection.toArray());
+        }
+
+        @Override
+        public int size() {
+            return collection.size();
+        }
+
+        @Override
+        public String toString() {
+            return getClass().getSimpleName() + "[" + name + "]";
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/StreamTestDataProvider.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream;
+
+import org.openjdk.tests.java.util.LambdaTestHelpers;
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.function.Combiner;
+
+/**
+ * StreamTestDataProvider
+ *
+ * @author Brian Goetz
+ */
+public class StreamTestDataProvider {
+    private static final Integer[] to0 = new Integer[0];
+    private static final Integer[] to1 = new Integer[1];
+    private static final Integer[] to10 = new Integer[10];
+    private static final Integer[] to100 = new Integer[100];
+    private static final Integer[] to1000 = new Integer[1000];
+    private static final Integer[] reversed = new Integer[100];
+    private static final Integer[] ones = new Integer[100];
+    private static final Integer[] twice = new Integer[200];
+    private static final Integer[] pseudoRandom;
+
+    private static final Object[][] testData;
+
+    static {
+        Integer[][] arrays = {to0, to1, to10, to100, to1000};
+        for (Integer[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        List<Object[]> list = new ArrayList<>();
+        for (Object[] data : arrays) {
+            final Object name = data[0];
+            final Integer[] ints = (Integer[])data[1];
+
+            list.add(e("array:" + name, ints, StreamTestData.ArrayData::new));
+            list.add(e("ArrayList.asList:" + name, Arrays.asList(ints), StreamTestData.CollectionData::new));
+            list.add(e("ArrayList:" + name, new ArrayList<>(Arrays.asList(ints)), StreamTestData.CollectionData::new));
+            list.add(e("HashSet:" + name, new HashSet<>(Arrays.asList(ints)), StreamTestData.CollectionData::new));
+            list.add(e("TreeSet:" + name, new TreeSet<>(Arrays.asList(ints)), StreamTestData.CollectionData::new));
+        }
+        testData = list.toArray(new Object[0][]);
+    }
+
+    static <T> Object[] e(String description, T[] data, Combiner<StreamTestData<T>, String, T[]> m) {
+        return new Object[] { description, m.combine(description, data) };
+    }
+
+    static <T> Object[] e(String description, Collection<T> data, Combiner<StreamTestData<T>, String, Collection<T>> m) {
+        return new Object[] { description, m.combine(description, data) };
+    }
+
+    // Return an array of ( String name, TestData<Integer> )
+    @DataProvider(name = "opArrays")
+    public static Object[][] makeValueTestData() {
+        return testData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ConcatOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.LambdaTestHelpers;
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+import sun.jvmstat.monitor.IntegerMonitor;
+
+import java.util.*;
+import java.util.stream.Streams;
+import java.util.stream.op.ConcatOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+@Test
+public class ConcatOpTest extends OpTestCase {
+
+    public void testRawIterator() {
+        assertCountSum(Iterators.concat(countTo(0).iterator(), countTo(0).iterator()), 0, 0);
+        assertCountSum(Iterators.concat(countTo(4).iterator(), countTo(0).iterator()), 4, 10);
+        assertCountSum(Iterators.concat(countTo(0).iterator(), countTo(4).iterator()), 4, 10);
+        assertCountSum(Iterators.concat(countTo(4).iterator(), countTo(4).iterator()), 8, 20);
+
+        List<Iterator<Integer>> lis = new ArrayList<>();
+        for (int i = 1; i < 8; i += 2) {
+            lis.add(range(i, i + 1).iterator());
+        }
+        assertCountSum(Iterators.concat(lis.iterator()), 8, 36);
+    }
+
+    public void testRawIteratorRemove() {
+        List<List<Integer>> ls = Streams.repeat(2, 2).
+                map(LambdaTestHelpers::countTo).into(new ArrayList<List<Integer>>());
+
+        List<Iterator<Integer>> lis = ls.stream().
+                map(i -> i.iterator()).into(new ArrayList<Iterator<Integer>>());
+
+        Iterator<Integer> i = Iterators.concat(lis.iterator());
+        while (i.hasNext()) {
+            i.next();
+            i.remove();
+        }
+
+        assertTrue(ls.stream().allMatch(l -> l.isEmpty()));
+    }
+
+    @Test(expectedExceptions = {IllegalStateException.class})
+    public void testRawIteratorRemoveTwice() {
+        Iterator<Integer> i = Iterators.concat(countTo(2).iterator(), countTo(2).iterator());
+        i.next();
+        i.remove();
+        i.remove();
+    }
+
+    @Test(expectedExceptions = {IllegalStateException.class})
+    public void testRawIteratorRemoveFirst() {
+        Iterator<Integer> i = Iterators.concat(countTo(2).iterator(), countTo(2).iterator());
+        i.remove();
+    }
+
+    public void testConcat() {
+        assertContents(Collections.<Integer>emptyList().stream().
+                concat(Collections.<Integer>emptyList().stream()).iterator(),
+                       Collections.<Integer>emptyList().iterator());
+
+        assertContents(countTo(10).stream().
+                concat(Collections.<Integer>emptyList().stream()).iterator(),
+                       countTo(10).stream().iterator());
+
+        assertContents(countTo(5).stream().
+                concat(range(6, 10).stream()).iterator(),
+                       countTo(10).stream().iterator());
+
+        assertContents(countTo(2).stream().
+                concat(range(3, 4).stream()).
+                concat(range(5, 6).stream()).
+                concat(range(7, 8).stream()).
+                concat(range(9, 10).stream()).iterator(),
+                       countTo(10).stream().iterator());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsSequential(String name, StreamTestData<Integer> data) {
+        withData(data).
+                usingOpFactory(() -> new ConcatOp<>(data.stream())).
+                exercise();
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsParallel(String name, StreamTestData<Integer> data) {
+        withData(data).
+                usingOpFactory(() -> new ConcatOp<>(data.parallel())).
+                exercise();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/CumulateOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.stream.op.*;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * CumulateOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class CumulateOpTest extends OpTestCase {
+    public void testRawIterator() {
+        assertCountSum(CumulateOp.iterator(countTo(0).iterator(), rPlus), 0, 0);
+        assertContents(CumulateOp.iterator(countTo(5).iterator(), rPlus), 1, 3, 6, 10, 15);
+        assertContents(CumulateOp.iterator(countTo(5).iterator(), rMax), 1, 2, 3, 4, 5);
+        assertContents(CumulateOp.iterator(countTo(5).iterator(), rMin), 1, 1, 1, 1, 1);
+    }
+
+    public void testCumulate() {
+        assertCountSum(countTo(0).stream().cumulate(rPlus), 0, 0);
+        assertContents(countTo(5).stream().cumulate(rPlus).iterator(), 1, 3, 6, 10, 15);
+        assertContents(countTo(5).stream().map(mDoubler).cumulate(rPlus).iterator(), 2, 6, 12, 20, 30);
+        assertContents(countTo(5).stream().cumulate(rMax).iterator(), 1, 2, 3, 4, 5);
+        assertContents(countTo(5).stream().cumulate(rMin).iterator(), 1, 1, 1, 1, 1);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        Node<Integer> result = exerciseOps(data, new CumulateOp<>(rPlus));
+        assertEquals(result.size(), data.size());
+
+        result = exerciseOps(data, new CumulateOp<>(rMin));
+        assertEquals(result.size(), data.size());
+
+        result = exerciseOps(data, new CumulateOp<>(rMax));
+        assertEquals(result.size(), data.size());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testWithFilter(String name, StreamTestData<Integer> data) {
+        exerciseOps(data, new FilterOp<>(pEven), new CumulateOp<>(rPlus));
+        exerciseOps(data, new FilterOp<>(pEven), new MapOp<>(mDoubler), new CumulateOp<>(rPlus));
+        exerciseOps(data, new FilterOp<Integer>(x -> x == -1), new CumulateOp<>(rPlus));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FilterOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Iterators;
+import java.util.stream.op.FilterOp;
+import java.util.stream.op.Node;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * FilterOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class FilterOpTest extends OpTestCase {
+    public void testRawIterator() {
+        assertCountSum(Iterators.filter(countTo(0).iterator(), pTrue), 0, 0);
+        assertCountSum(Iterators.filter(countTo(10).iterator(), pFalse), 0, 0);
+        assertCountSum(Iterators.filter(countTo(10).iterator(), pEven), 5, 30);
+        assertCountSum(Iterators.filter(countTo(10).iterator(), pOdd), 5, 25);
+        assertCountSum(Iterators.filter(countTo(10).iterator(), pTrue), 10, 55);
+        assertCountSum(Iterators.filter(Iterators.filter(countTo(10).iterator(), pEven), pOdd), 0, 0);
+    }
+
+    public void testFilter() {
+        assertCountSum(countTo(0).stream().filter(pTrue), 0, 0);
+        assertCountSum(countTo(10).stream().filter(pFalse), 0, 0);
+        assertCountSum(countTo(10).stream().filter(pEven), 5, 30);
+        assertCountSum(countTo(10).stream().filter(pOdd), 5, 25);
+        assertCountSum(countTo(10).stream().filter(pTrue), 10, 55);
+        assertCountSum(countTo(10).stream().filter(pEven).filter(pOdd), 0, 0);
+
+        exerciseOps(countTo(1000), s -> s.filter(pTrue), countTo(1000));
+        exerciseOps(countTo(1000), s -> s.filter(pFalse), countTo(0));
+        exerciseOps(countTo(1000), s -> s.filter(e -> e > 100), range(101, 1000));
+        exerciseOps(countTo(1000), s -> s.filter(e -> e < 100), countTo(99));
+        exerciseOps(countTo(1000), s -> s.filter(e -> e == 100), Arrays.asList(100));
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        Node<Integer> result = exerciseOps(data, new FilterOp<>(pTrue));
+        assertEquals(result.size(), data.size());
+
+        result = exerciseOps(data, new FilterOp<>(pFalse));
+        assertEquals(result.size(), 0);
+
+        exerciseOps(data, new FilterOp<>(pEven));
+        exerciseOps(data, new FilterOp<>(pOdd));
+
+        result = exerciseOps(data, new FilterOp<>(pOdd.and(pEven)));
+        assertEquals(result.size(), 0);
+
+        result = exerciseOps(data, new FilterOp<>(pOdd.or(pEven)));
+        assertEquals(result.size(), data.size());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FindAnyOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.Optional;
+import java.util.function.BiPredicate;
+import java.util.stream.op.FilterOp;
+import java.util.stream.op.FindAnyOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+
+/**
+ * FindAnyOpTest
+ *
+ */
+@Test
+public class FindAnyOpTest extends OpTestCase {
+    public void testRawIterator() {
+        FindAnyOp<Integer> op = FindAnyOp.singleton();
+        assertFalse(op.evaluate(Collections.<Integer>emptyIterator()).isPresent(), "no result");
+        assertTrue(op.evaluate(countTo(10).iterator()).isPresent(), "with result");
+    }
+
+    public void testFindAny() {
+        assertFalse(Collections.<Integer>emptySet().stream().findAny().isPresent(), "no result");
+        assertFalse(countTo(10).stream().filter(x -> x > 10).findAny().isPresent(), "no result");
+        assertTrue(countTo(10).stream().filter(pEven).findAny().isPresent(), "with result");
+    }
+
+    public void testFindAnyParallel() {
+        assertFalse(Collections.<Integer>emptySet().parallel().findAny().isPresent(), "no result");
+        assertFalse(countTo(1000).parallel().filter(x -> x > 1000).findAny().isPresent(), "no result");
+        assertTrue(countTo(1000).parallel().filter(pEven).findAny().isPresent(), "with result");
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        // @@@ Weak test -- only tests that all versions either find an answer or don't, don't assert validity of answer
+        // Would be good to test that the result is actually a member of the stream
+        BiPredicate<Optional<Integer>, Optional<Integer>> validAnswer = (a, b) -> a.isPresent() == b.isPresent();
+        exerciseOps(data, validAnswer, FindAnyOp.<Integer>singleton());
+        exerciseOps(data, validAnswer, FindAnyOp.<Integer>singleton(), new FilterOp<>(pTrue));
+        exerciseOps(data, validAnswer, FindAnyOp.<Integer>singleton(), new FilterOp<>(pEven));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FindFirstOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.stream.op.FilterOp;
+import java.util.stream.op.FindFirstOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+
+/**
+ * FindFirstOpTest
+ *
+ */
+@Test
+public class FindFirstOpTest extends OpTestCase {
+    public void testRawIterator() {
+        FindFirstOp<Integer> op = FindFirstOp.singleton();
+        assertFalse(op.evaluate(Collections.<Integer>emptyIterator()).isPresent(), "no result");
+        assertEquals(1, (int) op.evaluate(countTo(10).iterator()).get(), "first element is 1");
+    }
+
+    public void testFindFirst() {
+        assertFalse(Collections.<Integer>emptySet().stream().findFirst().isPresent(), "no result");
+        assertFalse(countTo(10).stream().filter(x -> x > 10).findFirst().isPresent(), "no result");
+
+        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(pEven).findFirst().get() }).stream(), Arrays.asList(2));
+        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.findFirst().get() }).stream(), Arrays.asList(1));
+        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(e -> e == 499).findFirst().get() }).stream(), Arrays.asList(499));
+        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(e -> e == 999).findFirst().get() }).stream(), Arrays.asList(999));
+        exerciseOps(countTo(0), s-> Arrays.asList(new Integer[] { s.findFirst().orElse(-1) }).stream(), Arrays.asList(-1));
+        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(e -> e == 1499).findFirst().orElse(-1) }).stream(), Arrays.asList(-1));
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        exerciseOps(data, FindFirstOp.<Integer>singleton());
+        exerciseOps(data, FindFirstOp.<Integer>singleton(), new FilterOp<>(pEven));
+        exerciseOps(data, FindFirstOp.<Integer>singleton(), new FilterOp<>(pTrue));
+        exerciseOps(data, FindFirstOp.<Integer>singleton(), new FilterOp<>(pFalse));
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testPipelines(String name, StreamTestData<Integer> data) {
+        Optional<Integer> seq, par;
+        seq = data.stream().findFirst();
+        par = data.parallel().findFirst();
+        assertEquals(par, seq);
+
+        seq = data.stream().filter(pEven).findFirst();
+        par = data.parallel().filter(pEven).findFirst();
+        assertEquals(par, seq);
+
+        seq = data.stream().filter(pTrue).findFirst();
+        par = data.parallel().filter(pTrue).findFirst();
+        assertEquals(par, seq);
+
+        seq = data.stream().filter(pFalse).findFirst();
+        par = data.parallel().filter(pFalse).findFirst();
+        assertEquals(par, seq);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamIntermediateOpTestScenario;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.*;
+import java.util.function.Supplier;
+import java.util.stream.Sink;
+import java.util.stream.StreamOpFlags;
+import java.util.stream.op.*;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.countTo;
+
+@Test
+public class FlagOpTest extends OpTestCase {
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testFlagsPassThrough(String name, StreamTestData<Integer> data) {
+
+        @SuppressWarnings({"unchecked", "rawtypes"})
+        TestFlagPassThroughOp<Integer>[] ops = new TestFlagPassThroughOp[3];
+        ops[0] = new TestFlagPassThroughOp<>();
+        ops[1] = new TestFlagPassThroughOp<>();
+        ops[2] = new TestFlagPassThroughOp<>();
+
+        ops[0].set(null, ops[1]);
+        ops[1].set(ops[0], ops[2]);
+        ops[2].set(ops[1], null);
+
+        exerciseOps(data, ops);
+    }
+
+    static class TestFlagPassThroughOp<T> extends FlagDeclaringOp<T> {
+        TestFlagPassThroughOp<T> upstream;
+        TestFlagPassThroughOp<T> downstream;
+
+        TestFlagPassThroughOp() {
+            super(0);
+        }
+
+        void set(TestFlagPassThroughOp<T> upstream, TestFlagPassThroughOp<T> downstream)  {
+            this.upstream = upstream;
+            this.downstream = downstream;
+        }
+
+        int wrapFlags;
+
+        @Override
+        public Iterator<T> wrapIterator(int flags, Iterator<T> source) {
+            this.wrapFlags = flags;
+
+            if (upstream != null) {
+                assertTrue(flags == upstream.wrapFlags);
+            }
+
+            return source;
+        }
+
+        @Override
+        @SuppressWarnings({"unchecked", "rawtypes"})
+        public Sink<T> wrapSink(int flags, Sink sink) {
+            this.wrapFlags = flags;
+
+            if (downstream != null) {
+                assertTrue(flags == downstream.wrapFlags);
+            }
+
+            return sink;
+        }
+    }
+
+    public void testFlagsClearAllSet() {
+        int clearAllFlags = 0;
+        for (StreamOpFlags f : EnumSet.allOf(StreamOpFlags.class)) {
+            if (f.isStreamFlag()) {
+                clearAllFlags |= f.clear();
+            }
+        }
+
+        EnumSet<StreamOpFlags> known = EnumSet.noneOf(StreamOpFlags.class);
+        EnumSet<StreamOpFlags> notKnown = StreamOpFlags.allOfStreamFlags();
+
+        List<FlagDeclaringOp<Integer>> ops = new ArrayList<>();
+        ops.add(new FlagDeclaringOp<>(clearAllFlags));
+        for (StreamOpFlags f : StreamOpFlags.allOfStreamFlags()) {
+            ops.add(new TestFlagExpectedOp<>(f.set(),
+                                             known.clone(),
+                                             EnumSet.noneOf(StreamOpFlags.class),
+                                             notKnown.clone()));
+            known.add(f);
+            notKnown.remove(f);
+        }
+        ops.add(new TestFlagExpectedOp<>(0,
+                                         known.clone(),
+                                         EnumSet.noneOf(StreamOpFlags.class),
+                                         notKnown.clone()));
+
+        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
+        @SuppressWarnings("rawtypes")
+        FlagDeclaringOp[] opsArray = ops.toArray(new FlagDeclaringOp[ops.size()]);
+
+        withData(data).
+                using(opsArray).
+                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
+                exercise();
+    }
+
+    public void testFlagsSetAllClear() {
+        int setAllFlags = 0;
+        for (StreamOpFlags f : EnumSet.allOf(StreamOpFlags.class)) {
+            if (f.isStreamFlag()) {
+                setAllFlags |= f.set();
+            }
+        }
+
+        EnumSet<StreamOpFlags> known = StreamOpFlags.allOfStreamFlags();
+        EnumSet<StreamOpFlags> notKnown = EnumSet.noneOf(StreamOpFlags.class);
+
+        List<FlagDeclaringOp<Integer>> ops = new ArrayList<>();
+        ops.add(new FlagDeclaringOp<>(setAllFlags));
+        for (StreamOpFlags f : StreamOpFlags.allOfStreamFlags()) {
+            ops.add(new TestFlagExpectedOp<>(f.clear(),
+                                             known.clone(),
+                                             EnumSet.noneOf(StreamOpFlags.class),
+                                             notKnown.clone()));
+            known.remove(f);
+            notKnown.add(f);
+        }
+        ops.add(new TestFlagExpectedOp<>(0,
+                                         known.clone(),
+                                         EnumSet.noneOf(StreamOpFlags.class),
+                                         notKnown.clone()));
+
+        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
+        @SuppressWarnings("rawtypes")
+        FlagDeclaringOp[] opsArray = ops.toArray(new FlagDeclaringOp[ops.size()]);
+
+
+        withData(data).
+                using(opsArray).
+                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
+                exercise();
+    }
+
+    public void testFlagsSetParallelCollect() {
+        testFlagsSetSequence(CollectorOps::parallelCollector);
+    }
+
+    public void testFlagsSetSequentialCollect() {
+        testFlagsSetSequence(CollectorOps::sequentialCollector);
+    }
+
+    private void testFlagsSetSequence(Supplier<StatefulOp<Integer, Integer>> cf) {
+        EnumSet<StreamOpFlags> known = EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED);
+        EnumSet<StreamOpFlags> preserve = EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED);
+
+        List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
+        for (StreamOpFlags f : EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED)) {
+            ops.add(cf.get());
+            ops.add(new TestFlagExpectedOp<>(f.set(),
+                                             known.clone(),
+                                             preserve.clone(),
+                                             EnumSet.noneOf(StreamOpFlags.class)));
+            known.add(f);
+            preserve.remove(f);
+        }
+        ops.add(cf.get());
+        ops.add(new TestFlagExpectedOp<>(0,
+                                         known.clone(),
+                                         preserve.clone(),
+                                         EnumSet.noneOf(StreamOpFlags.class)));
+
+        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
+        @SuppressWarnings("rawtypes")
+        IntermediateOp[] opsArray = ops.toArray(new IntermediateOp[ops.size()]);
+
+        withData(data).
+                using(opsArray).
+                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
+                exercise();
+    }
+
+
+    public void testFlagsClearParallelCollect() {
+        testFlagsClearSequence(CollectorOps::parallelCollector);
+    }
+
+    public void testFlagsClearSequentialCollect() {
+        testFlagsClearSequence(CollectorOps::sequentialCollector);
+    }
+
+    protected void testFlagsClearSequence(Supplier<StatefulOp<Integer, Integer>> cf) {
+        EnumSet<StreamOpFlags> preserve = EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED);
+        EnumSet<StreamOpFlags> notKnown = EnumSet.noneOf(StreamOpFlags.class);
+
+        List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
+        for (StreamOpFlags f : EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED)) {
+            ops.add(cf.get());
+            ops.add(new TestFlagExpectedOp<>(f.clear(),
+                                             EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED),
+                                             preserve.clone(),
+                                             notKnown));
+            notKnown.add(f);
+            preserve.remove(f);
+        }
+        ops.add(cf.get());
+        ops.add(new TestFlagExpectedOp<>(0,
+                                         EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED),
+                                         preserve.clone(),
+                                         EnumSet.noneOf(StreamOpFlags.class)));
+
+        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
+        @SuppressWarnings("rawtypes")
+        IntermediateOp[] opsArray = ops.toArray(new IntermediateOp[ops.size()]);
+
+        withData(data).
+                using(opsArray).
+                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
+                exercise();
+    }
+
+    public void testFlagsSizedOrderedParallelCollect() {
+        EnumSet<StreamOpFlags> parKnown = EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED);
+        EnumSet<StreamOpFlags> serKnown = parKnown.clone();
+
+        List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
+        for (StreamOpFlags f : parKnown) {
+            ops.add(CollectorOps.<Integer>parallelCollector());
+            ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
+                                             parKnown,
+                                             serKnown));
+            serKnown.remove(f);
+        }
+        ops.add(CollectorOps.<Integer>parallelCollector());
+        ops.add(new ParSerTestFlagExpectedOp<>(0,
+                                         parKnown,
+                                         EnumSet.noneOf(StreamOpFlags.class)));
+
+        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
+        @SuppressWarnings("rawtypes")
+        IntermediateOp[] opsArray = ops.toArray(new IntermediateOp[ops.size()]);
+
+        exerciseOps(data, opsArray);
+    }
+
+    static class ParSerTestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
+        final EnumSet<StreamOpFlags> parKnown;
+        final EnumSet<StreamOpFlags> serKnown;
+
+        ParSerTestFlagExpectedOp(int flags, EnumSet<StreamOpFlags> known, EnumSet<StreamOpFlags> serKnown) {
+            super(flags);
+            this.parKnown = known;
+            this.serKnown = serKnown;
+        }
+
+        @Override
+        public Iterator<T> wrapIterator(int flags, Iterator<T> downstream) {
+            assertFlags(flags);
+            return downstream;
+        }
+
+        @Override
+        @SuppressWarnings({"unchecked", "rawtypes"})
+        public Sink<T> wrapSink(int flags, Sink upstream) {
+            assertFlags(flags);
+            return upstream;
+        }
+
+        protected void assertFlags(int flags) {
+            if (StreamOpFlags.PARALLEL.isKnown(flags)) {
+                for (StreamOpFlags f : parKnown) {
+                    Assert.assertTrue(f.isKnown(flags), String.format("Flag %s is not known, but should be known.", f.toString()));
+                }
+
+            } else {
+                for (StreamOpFlags f : serKnown) {
+                    Assert.assertTrue(f.isKnown(flags), String.format("Flag %s is not known, but should be known.", f.toString()));
+                }
+
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FlatMapOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.function.Block;
+import java.util.function.FlatMapper;
+import java.util.stream.Stream;
+import java.util.stream.op.FlatMapOp;
+import java.util.stream.op.Node;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * FlatMapOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class FlatMapOpTest extends OpTestCase {
+    private static final FlatMapper<Integer, Integer> mfIntToBits = (block, integer) -> {
+        int num = integer;
+        for (int i = 0; i < 16 && num != 0; i++) {
+            if ((num & (1 << i)) != 0) {
+                num &= ~(1 << i);
+                block.apply(i);
+            }
+        }
+    };
+
+    public void testRawIterator() {
+        assertCountSum(FlatMapOp.iterator(countTo(10).iterator(), mfId), 10, 55);
+        assertCountSum(FlatMapOp.iterator(countTo(10).iterator(), mfNull), 0, 0);
+        assertCountSum(FlatMapOp.iterator(countTo(3).iterator(), mfLt), 6, 4);
+    }
+
+    public void testFlatMap() {
+        String[] stringsArray = {"hello", "there", "", "yada"};
+        Stream<String> strings = Arrays.asList(stringsArray).stream();
+        assertConcat(strings.flatMap(flattenChars).iterator(), "hellothereyada");
+
+        assertCountSum(countTo(10).stream().flatMap(mfId), 10, 55);
+        assertCountSum(countTo(10).stream().flatMap(mfNull), 0, 0);
+        assertCountSum(countTo(3).stream().flatMap(mfLt), 6, 4);
+
+        exerciseOps(new StreamTestData.ArrayData<>("stringsArray", stringsArray), new FlatMapOp<>(flattenChars));
+        exerciseOps(new StreamTestData.ArrayData<>("LONG_STRING", new String[]{LONG_STRING}), new FlatMapOp<>(flattenChars));
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        Node<Integer> result = exerciseOps(data, new FlatMapOp<>(mfId));
+        assertEquals(data.size(), result.size());
+
+        result = exerciseOps(data, new FlatMapOp<>(mfNull));
+        assertEquals(0, result.size());
+
+        result = exerciseOps(data, new FlatMapOp<>(mfId));
+        assertEquals(result.size(), data.size());
+
+        exerciseOps(data, new FlatMapOp<>(mfLt));
+        exerciseOps(data, new FlatMapOp<>(mfIntToBits));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ForEachOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.op.ForEachOp;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * ForEachOpTest
+ */
+@Test
+public class ForEachOpTest extends OpTestCase {
+
+    public void testForEachParallel() {
+        AtomicInteger count = new AtomicInteger(0);
+        AtomicInteger sum = new AtomicInteger(0);
+        countTo(10).parallel().forEach(e -> { count.incrementAndGet(); sum.addAndGet(e); });
+        assertEquals(count.get(), 10);
+        assertEquals(sum.get(), 55);
+    }
+
+    public void testForEachStream() {
+        List<Integer> counted = countTo(10);
+        List<Integer> eached = new ArrayList<>();
+        counted.stream().forEach(e -> { eached.add(e); });
+        assertContents(eached.iterator(), counted.iterator());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    @SuppressWarnings("unchecked")
+    public void testOps(String name, StreamTestData<Integer> data) {
+       Object result = exerciseOps(data, ForEachOp.<Integer>make(bEmpty));
+       assertEquals(result, null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/GroupByOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.Stream;
+import java.util.stream.StreamOpFlags;
+import java.util.stream.op.GroupByOp;
+import java.util.stream.op.FlagDeclaringOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * GroupByOpTest
+ *
+ */
+@Test
+public class GroupByOpTest extends OpTestCase {
+
+    public void testRawIterator() {
+        GroupByOp<Integer, Boolean> grouping = new GroupByOp<>(Functions.forPredicate(pEven, true, false));
+
+        Map<Boolean,Collection<Integer>> result = iteratorToStatefulSink(countTo(10).iterator(), grouping.sink());
+
+        assertEquals(2, result.keySet().size());
+        for(Collection<Integer> group : result.values()) {
+            int count = 0;
+            Stream<Integer> stream = group.stream();
+            Iterator<Integer> it = stream.iterator();
+            while (it.hasNext()) {
+                it.next();
+                ++count;
+            }
+            assertEquals(5, count);
+        }
+    }
+
+    public void testGroupBy() {
+        Map<Boolean,Collection<Integer>> result = countTo(10).stream().groupBy(Functions.forPredicate(pEven, true, false));
+
+        assertEquals(2, result.keySet().size());
+        for(Collection<Integer> group : result.values()) {
+            int count = 0;
+            Stream<Integer> stream = group.stream();
+            Iterator<Integer> it = stream.iterator();
+            while (it.hasNext()) {
+                it.next();
+                ++count;
+            }
+            assertEquals(5, count);
+        }
+    }
+
+    static class MapperData<T, K> {
+        Function<K, T> m;
+        int expectedSize;
+
+        MapperData(Function<K, T> m, int expectedSize) {
+            this.m = m;
+            this.expectedSize = expectedSize;
+        }
+    }
+
+    List<MapperData<Integer, ?>> getMapperData(StreamTestData<Integer> data) {
+        int uniqueSize = data.into(new HashSet<>()).size();
+
+        return Arrays.<MapperData<Integer, ?>>asList(
+            new MapperData<>(mId, uniqueSize),
+            new MapperData<>(mZero, Math.min(1, data.size())),
+            new MapperData<>(mDoubler, uniqueSize),
+            new MapperData<>(mId.compose(mDoubler), uniqueSize),
+            new MapperData<>(mDoubler.compose(mDoubler), uniqueSize),
+
+            new MapperData<>(Functions.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
+            new MapperData<>(Functions.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
+            new MapperData<>(Functions.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
+            new MapperData<>(Functions.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
+        );
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        // @@@ More things to test here:
+        //     - Every value in data is present in right bucket
+        //     - Total number of values equals size of data
+
+        for (MapperData<Integer, ?> md : getMapperData(data)) {
+            Map<?, Collection<Integer>> result = exerciseOps(data,
+                                                             new GroupByOp<Integer, Object>(md.m));
+            assertEquals(result.keySet().size(), md.expectedSize);
+        }
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testWithUnorderedOp(String name, StreamTestData<Integer> data) {
+        // @@@ More things to test here:
+        //     - Every value in data is present in right bucket
+        //     - Total number of values equals size of data
+
+        for (MapperData<Integer, ?> md : getMapperData(data)) {
+            Map<?, Collection<Integer>> result = exerciseOps(data,
+                                                             this::multiMapEquals,
+                                                             new GroupByOp<Integer, Object>(md.m),
+                                                             new FlagDeclaringOp<>(StreamOpFlags.NOT_ORDERED));
+            assertEquals(result.keySet().size(), md.expectedSize);
+        }
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testWithValueFactory(String name, StreamTestData<Integer> data) {
+        Map<Integer, Collection<Integer>> miResult = exerciseOps(data, new GroupByOp<Integer, Integer>(mId, LinkedList::new));
+
+        Set<Class<?>> classes = miResult.values().stream().map(e -> e.getClass()).into(new HashSet<Class<?>>());
+
+        if (data.size() > 0) {
+            assertEquals(classes.size(), 1);
+            assertEquals(LinkedList.class, classes.iterator().next());
+        }
+    }
+
+    <K, V> boolean multiMapEquals(Map<K, Collection<V>> a, Map<K, Collection<V>> b) {
+        if (!Objects.equals(a.keySet(), b.keySet())) {
+            return false;
+        }
+
+        for (K k : a.keySet()) {
+            Set<V> as = new HashSet<>(a.get(k));
+            Set<V> bs = new HashSet<>(b.get(k));
+            if (!Objects.equals(as, bs)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/InfiniteStreamWithLimitOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.stream.Stream;
+import java.util.stream.Streams;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.assertContents;
+
+
+@Test
+public class InfiniteStreamWithLimitOpTest extends OpTestCase {
+
+    public void testRepeatLimit() {
+        assertContents(
+                Streams.repeat("A").limit(10).iterator(),
+                Streams.repeat(10, "A").iterator());
+    }
+
+    public void testRepeatedlyLimit() {
+        assertContents(
+                Streams.repeatedly(() -> "A").limit(10).iterator(),
+                Streams.repeatedly(10, () -> "A").iterator());
+    }
+
+    public void testIterateLimit() {
+        assertContents(
+                Streams.iterate("A", s -> s).limit(10).iterator(),
+                Streams.repeat(10, "A").iterator());
+    }
+
+    public void testIterateFibLimit() {
+        Stream<Integer> fib = Streams.
+                iterate(new int[]{0, 1}, pair -> new int[]{pair[1], pair[0] + pair[1]}).
+                map(pair -> (Integer) pair[0]);
+
+        assertContents(
+                fib.limit(10).iterator(),
+                Arrays.asList(0, 1, 1, 2, 3, 5, 8, 13, 21, 34).iterator());
+    }
+
+    public void testEmptyCycle() {
+        assertContents(
+                Streams.cycle(Collections.emptyList()).iterator(),
+                Collections.emptyList().iterator());
+    }
+
+    public void testCycleLimit() {
+        assertContents(
+                Streams.cycle(Arrays.asList(0, 1, 2, 3)).limit(16).iterator(),
+                Streams.iterate(0, i -> (i + 1) % 4).limit(16).iterator());
+    }
+
+    public void testCycleSkipLimit() {
+        assertContents(
+                Streams.cycle(Arrays.asList(0, 1, 2, 3)).skip(2).limit(16).iterator(),
+                Streams.iterate(2, i -> (i + 1) % 4).limit(16).iterator());
+    }
+
+    public void testInfiniteToMatchOp() {
+        assertFalse(Streams.cycle(Arrays.asList(1, 2, 3, 4)).allMatch(i -> i > 3));
+        assertTrue(Streams.cycle(Arrays.asList(1, 2, 3, 4)).anyMatch(i -> i > 3));
+        assertFalse(Streams.cycle(Arrays.asList(1, 2, 3, 4)).noneMatch(i -> i > 3));
+    }
+
+    public void testInfiniteWithLimitToShortCircuitTerminal() {
+        Streams.repeat(1).limit(4).toArray();
+        Streams.repeat(1).limit(4).filter(i -> true).toArray();
+        Streams.repeat(1).limit(4).into(new ArrayList<>());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.op.Node;
+import java.util.stream.primitive.*;
+
+import static org.testng.Assert.*;
+
+@Test
+public class IntNodeTest {
+
+    @DataProvider(name = "nodes")
+    public Object[][] createSizes() {
+        List<Object[]> params = new ArrayList<>();
+
+        for (int size : Arrays.asList(0, 1, 4, 15, 16, 17, 127, 128, 129, 1000)) {
+            int[] array = new int[size];
+            for (int i = 0; i < array.length; i++) {
+                array[i] = i;
+            }
+
+            List<Node<Integer>> nodes = new ArrayList<>();
+
+            nodes.add(IntNodes.node(array));
+
+            nodes.add(degenerateTree(Primitives.iterator(array)));
+
+            nodes.add(tree(toList(array), l -> IntNodes.node(toIntArray(l))));
+
+            nodes.add(fill(array, IntNodes.makeBuilder(array.length)));
+
+            nodes.add(fill(array, IntNodes.makeVariableSizeBuilder()));
+
+            for (int i = 0; i < nodes.size(); i++) {
+                params.add(new Object[]{array, nodes.get(i)});
+            }
+
+        }
+
+        return params.toArray(new Object[0][]);
+    }
+
+    List<Integer> toList(int[] a) {
+        List<Integer> l = new ArrayList<>();
+        for (int i : a) {
+            l.add(i);
+        }
+
+        return l;
+    }
+
+    int[] toIntArray(List<Integer> l) {
+        int[] a = new int[l.size()];
+
+        int i = 0;
+        for (Integer e : l) {
+            a[i++] = e;
+        }
+        return a;
+    }
+
+    IntNode fill(int[] array, IntNodeBuilder nb) {
+        nb.begin(array.length);
+        for (Integer i : array) {
+            nb.applyInt(i);
+        }
+        nb.end();
+        return nb.build();
+    }
+
+    IntNode degenerateTree(IntIterator it) {
+        if (!it.hasNext()) {
+            return IntNodes.node(new int[0]);
+        }
+
+        int i = it.nextInt();
+        if (it.hasNext()) {
+            return IntNodes.node(IntNodes.node(new int[]{i}), degenerateTree(it));
+        }
+        else {
+            return IntNodes.node(new int[]{i});
+        }
+    }
+
+    IntNode tree(List<Integer> l, Function<IntNode, List<Integer>> m) {
+        if (l.size() < 3) {
+            return m.apply(l);
+        }
+        else {
+            return IntNodes.node(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
+        }
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testAsArray(int[] array, IntNode n) {
+        assertEquals(n.asIntArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testFlattenAsArray(int[] array, IntNode n) {
+        assertEquals(n.flatten().asIntArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testCopyTo(int[] array, IntNode n) {
+        int[] copy = new int[n.size()];
+        n.copyInto(copy, 0);
+
+        assertEquals(copy, array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testForEach(int[] array, IntNode n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        n.forEach(e -> {
+            l.add(e);
+        });
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testIterator(int[] array, IntNode n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        IntIterator it = n.iterator();
+        while (it.hasNext()) {
+            l.add(it.nextInt());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testRootSpliterator(int[] array, IntNode n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        IntIterator it = n.spliterator().iterator();
+        while (it.hasNext()) {
+            l.add(it.nextInt());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testDepthOneSpliterator(int[] array, IntNode n) {
+        List<Integer> l = new ArrayList<>(n.size());
+
+        IntSpliterator s = n.spliterator();
+        for (int i = 0; i < s.getNaturalSplits(); i++) {
+            IntIterator it = s.split().iterator();
+            while (it.hasNext()) {
+                l.add(it.nextInt());
+            }
+        }
+
+        IntIterator it = s.iterator();
+        while (it.hasNext()) {
+            l.add(it.nextInt());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testTwoSpliterator(int[] array, IntNode n) {
+        List<Integer> l = new ArrayList<>(n.size());
+
+        IntSpliterator s2 = n.spliterator();
+        IntSpliterator s1 = s2.split();
+
+        IntIterator it = s1.iterator();
+        while (it.hasNext()) {
+            l.add(it.nextInt());
+        }
+
+        it = s2.iterator();
+        while (it.hasNext()) {
+            l.add(it.nextInt());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testSpliterator(int[] array, IntNode n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        split(l, n.spliterator());
+
+        assertEquals(l.toArray(), array);
+    }
+
+    void split(List<Integer> l, IntSpliterator s) {
+        if (s.getNaturalSplits() == 0) {
+            IntSpliterator _s = s.split();
+            assertEquals(_s.getNaturalSplits(), 0);
+            assertFalse(_s.split().iterator().hasNext());
+
+            s.forEach(e -> {
+                l.add(e);
+            });
+        }
+        else {
+            int size = s.getSizeIfKnown();
+            for (int i = 0; i < s.getNaturalSplits(); i++) {
+                IntSpliterator _s = s.split();
+                split(l, _s);
+            }
+
+            assertTrue(s.getSizeIfKnown() < size);
+
+            split(l, s);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/MapOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Iterators;
+import java.util.function.Block;
+import java.util.stream.op.MapOp;
+import java.util.stream.op.Node;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * MapOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class MapOpTest extends OpTestCase {
+    public void testRawIterator() {
+        assertCountSum(Iterators.map(countTo(0).iterator(), mId), 0, 0);
+        assertCountSum(Iterators.map(countTo(10).iterator(), mId), 10, 55);
+        assertCountSum(Iterators.map(countTo(10).iterator(), mZero), 10, 0);
+        assertCountSum(Iterators.map(countTo(0).iterator(), mDoubler), 0, 0);
+        assertCountSum(Iterators.map(countTo(10).iterator(), mDoubler), 10, 110);
+        assertCountSum(Iterators.map(Iterators.map(countTo(10).iterator(), mDoubler), mDoubler), 10, 220);
+    }
+
+    public void testMap() {
+        assertCountSum(countTo(0).stream().map(mId), 0, 0);
+        assertCountSum(countTo(10).stream().map(mId), 10, 55);
+        assertCountSum(countTo(10).stream().map(mZero), 10, 0);
+        assertCountSum(countTo(0).stream().map(mDoubler), 0, 0);
+        assertCountSum(countTo(10).stream().map(mDoubler), 10, 110);
+        assertCountSum(countTo(10).stream().map(mDoubler).map(mDoubler), 10, 220);
+
+
+        exerciseOps(countTo(0), s -> s.map(e -> e), countTo(0));
+        exerciseOps(countTo(1000), s -> s.map(e -> e), countTo(1000));
+        exerciseOps(countTo(1000), s -> s.map(e -> (1000+e)), range(1001, 2000));
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        Node<Integer> result = exerciseOps(data, new MapOp<>(mId));
+        assertEquals(data.size(), result.size());
+
+        result = exerciseOps(data, new MapOp<>(mZero));
+        assertEquals(data.size(), result.size());
+
+        result = exerciseOps(data, new MapOp<>(mDoubler));
+        assertEquals(data.size(), result.size());
+
+        result = exerciseOps(data, new MapOp<>(mId.compose(mDoubler)));
+        assertEquals(data.size(), result.size());
+
+        result = exerciseOps(data, new MapOp<>(mDoubler.compose(mDoubler)));
+        assertEquals(data.size(), result.size());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/MatchOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.function.Predicate;
+import java.util.stream.Stream;
+import java.util.stream.Streamable;
+import java.util.stream.op.FilterOp;
+import java.util.stream.op.MatchOp;
+
+import static java.util.stream.op.MatchOp.MatchKind;
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * MatchOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class MatchOpTest extends OpTestCase {
+    @SuppressWarnings({ "unchecked", "raw" })
+    private static final Predicate<Integer>[] INTEGER_PREDICATES
+            = (Predicate<Integer>[]) new Predicate<?>[] { pTrue, pFalse, pEven, pOdd };
+
+    private<T> void assertPredicates(Streamable<Stream<T>> source, MatchKind matchKind, Predicate<T>[] predicates, boolean... answers) {
+        for (int i=0; i<predicates.length; i++) {
+            boolean match;
+            switch (matchKind) {
+                case ANY: match = source.stream().anyMatch(predicates[i]); break;
+                case ALL: match = source.stream().allMatch(predicates[i]); break;
+                case NONE: match = source.stream().noneMatch(predicates[i]); break;
+                default: throw new IllegalStateException();
+            }
+            assertEquals(answers[i], match, matchKind.toString() + predicates[i].toString());
+        }
+    }
+
+    public void testMatches() {
+        assertPredicates(countTo(0), MatchKind.ANY, INTEGER_PREDICATES, false, false, false, false);
+        assertPredicates(countTo(0), MatchKind.ALL, INTEGER_PREDICATES, true, true, true, true);
+        assertPredicates(countTo(0), MatchKind.NONE, INTEGER_PREDICATES, true, true, true, true);
+
+        assertPredicates(countTo(1), MatchKind.ANY, INTEGER_PREDICATES, true, false, false, true);
+        assertPredicates(countTo(1), MatchKind.ALL, INTEGER_PREDICATES, true, false, false, true);
+        assertPredicates(countTo(1), MatchKind.NONE, INTEGER_PREDICATES, false, true, true, false);
+
+        assertPredicates(countTo(5), MatchKind.ANY, INTEGER_PREDICATES, true, false, true, true);
+        assertPredicates(countTo(5), MatchKind.ALL, INTEGER_PREDICATES, true, false, false, false);
+        assertPredicates(countTo(5), MatchKind.NONE, INTEGER_PREDICATES, false, true, false, false);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        for (Predicate<Integer> p : INTEGER_PREDICATES)
+            for (MatchKind matchKind : MatchKind.values()) {
+                exerciseOps(data, MatchOp.make(p, matchKind));
+                exerciseOps(data, MatchOp.make(p, matchKind), new FilterOp<>(pFalse));
+                exerciseOps(data, MatchOp.make(p, matchKind), new FilterOp<>(pEven));
+            }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeBuilderTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.op.NodeBuilder;
+import java.util.stream.op.Nodes;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.assertContents;
+import static org.openjdk.tests.java.util.LambdaTestHelpers.countTo;
+import static org.testng.Assert.assertEquals;
+
+@Test
+public class NodeBuilderTest {
+
+    @DataProvider(name = "sizes")
+    public Object[][] createSizes() {
+        List<Integer> sizes = Arrays.asList(0, 1, 4, 16, 256,
+                                            1023, 1024, 1025,
+                                            2047, 2048, 2049,
+                                            1024 * 32 - 1, 1024 * 32, 1024 * 32 + 1);
+
+        List<List<Integer>> ls = new ArrayList<>();
+        for (Integer size : sizes) {
+            ls.add(countTo(size));
+        }
+
+        List<Function<NodeBuilder<Integer>, Integer>> ms = Arrays.<Function<NodeBuilder<Integer>, Integer>>asList(
+                s -> Nodes.makeVariableSizeBuilder(),
+                s -> Nodes.makeBuilder(s)
+        );
+
+        Object[][] params = new Object[ls.size() * ms.size()][];
+        int i = 0;
+        for (List<Integer> l : ls) {
+            for (Function<NodeBuilder<Integer>, Integer> m : ms) {
+                params[i++] = new Object[]{l, m};
+            }
+        }
+
+        return params;
+    }
+
+    @Test(dataProvider = "sizes")
+    public void testIteration(List<Integer> l, Function<NodeBuilder<Integer>, Integer> m) {
+        NodeBuilder<Integer> nb = m.apply(l.size());
+        nb.begin(l.size());
+        for (int i : l) {
+            nb.apply(i);
+        }
+        nb.end();
+
+        assertEquals(nb.size(), l.size());
+
+        {
+            List<Integer> _l = new ArrayList<>();
+            nb.forEach(e -> {
+                _l.add(e);
+            });
+
+            assertContents(_l, l);
+        }
+
+        {
+            List<Integer> _l = new ArrayList<>();
+            for (int i : nb) {
+                _l.add(i);
+            }
+
+            assertContents(_l, l);
+        }
+    }
+
+    @Test(dataProvider = "sizes")
+    public void testUpdate(List<Integer> l, Function<NodeBuilder<Integer>, Integer> m) {
+        NodeBuilder<Integer> nb = m.apply(l.size());
+        nb.begin(l.size());
+        for (int i : l) {
+            nb.apply(i);
+        }
+        nb.end();
+
+        // Negate each element
+        nb.forEachUpdate(e -> -e);
+
+        // Sum of original list and builder must be 0
+        int sum = 0;
+        Iterator<Integer> lit = l.iterator();
+        for (int i : nb) {
+            sum += i + lit.next();
+        }
+
+        assertEquals(sum, 0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Spliterator;
+import java.util.stream.Stream;
+import java.util.stream.Streamable;
+import java.util.stream.op.Node;
+import java.util.stream.op.NodeBuilder;
+import java.util.stream.op.Nodes;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+@Test
+public class NodeTest {
+
+    @DataProvider(name = "nodes")
+    public Object[][] createSizes() {
+        List<Object[]> params = new ArrayList<>();
+
+        for (int size : Arrays.asList(0, 1, 4, 15, 16, 17, 127, 128, 129, 1000)) {
+            Integer[] array = new Integer[size];
+            for (int i = 0; i < array.length; i++) {
+                array[i] = i;
+            }
+
+            List<Node<Integer>> nodes = new ArrayList<>();
+            nodes.add(Nodes.node(array));
+            nodes.add(Nodes.node(Arrays.asList(array)));
+            nodes.add(Nodes.node((Streamable<Stream<Integer>>) Arrays.asList(array)));
+            nodes.add(Nodes.node(Arrays.asList(array).stream()));
+            nodes.add(Nodes.node(Arrays.asList(array).parallel()));
+            nodes.add(degenerateTree(Arrays.asList(array).iterator()));
+            nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l.toArray(new Integer[l.size()]))));
+            nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l)));
+            nodes.add(fill(array, Nodes.<Integer>makeBuilder(array.length)));
+            nodes.add(fill(array, Nodes.<Integer>makeVariableSizeBuilder()));
+
+            for (int i = 0; i < nodes.size(); i++) {
+                params.add(new Object[]{array, nodes.get(i)});
+            }
+
+        }
+
+        return params.toArray(new Object[0][]);
+    }
+
+    Node<Integer> fill(Integer[] array, NodeBuilder<Integer> nb) {
+        nb.begin(array.length);
+        for (Integer i : array) {
+            nb.apply(i);
+        }
+        nb.end();
+        return nb.build();
+    }
+
+    Node<Integer> degenerateTree(Iterator<Integer> it) {
+        if (!it.hasNext()) {
+            return Nodes.node(Collections.<Integer>emptyList());
+        }
+
+        Integer i = it.next();
+        if (it.hasNext()) {
+            return Nodes.node(Nodes.node(new Integer[]{i}), degenerateTree(it));
+        }
+        else {
+            return Nodes.node(new Integer[]{i});
+        }
+    }
+
+    Node<Integer> tree(List<Integer> l, Function<Node<Integer>, List<Integer>> m) {
+        if (l.size() < 3) {
+            return m.apply(l);
+        }
+        else {
+            return Nodes.node(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
+        }
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testAsArray(Integer[] array, Node<Integer> n) {
+        assertEquals(n.asArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testFlattenAsArray(Integer[] array, Node<Integer> n) {
+        assertEquals(n.flatten().asArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testCopyTo(Integer[] array, Node<Integer> n) {
+        Integer[] copy = new Integer[n.size()];
+        n.copyInto(copy, 0);
+
+        assertEquals(copy, array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testForEach(Integer[] array, Node<Integer> n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        n.forEach(e -> {
+            l.add(e);
+        });
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testIterator(Integer[] array, Node<Integer> n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        Iterator<Integer> it = n.iterator();
+        while (it.hasNext()) {
+            l.add(it.next());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testRootSpliterator(Integer[] array, Node<Integer> n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        Iterator<Integer> it = n.spliterator().iterator();
+        while (it.hasNext()) {
+            l.add(it.next());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testDepthOneSpliterator(Integer[] array, Node<Integer> n) {
+        List<Integer> l = new ArrayList<>(n.size());
+
+        Spliterator<Integer> s = n.spliterator();
+        for (int i = 0; i < s.getNaturalSplits(); i++) {
+            Iterator<Integer> it = s.split().iterator();
+            while (it.hasNext()) {
+                l.add(it.next());
+            }
+        }
+
+        Iterator<Integer> it = s.iterator();
+        while (it.hasNext()) {
+            l.add(it.next());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testTwoSpliterator(Integer[] array, Node<Integer> n) {
+        List<Integer> l = new ArrayList<>(n.size());
+
+        Spliterator<Integer> s2 = n.spliterator();
+        Spliterator<Integer> s1 = s2.split();
+
+        Iterator<Integer> it = s1.iterator();
+        while (it.hasNext()) {
+            l.add(it.next());
+        }
+
+        it = s2.iterator();
+        while (it.hasNext()) {
+            l.add(it.next());
+        }
+
+        assertEquals(l.toArray(), array);
+    }
+
+    @Test(dataProvider = "nodes")
+    public void testSpliterator(Integer[] array, Node<Integer> n) {
+        List<Integer> l = new ArrayList<>(n.size());
+        split(l, n.spliterator());
+
+        assertEquals(l.toArray(), array);
+    }
+
+    void split(List<Integer> l, Spliterator<Integer> s) {
+        if (s.getNaturalSplits() == 0) {
+            Spliterator<Integer> _s = s.split();
+            assertEquals(_s.getNaturalSplits(), 0);
+            assertFalse(_s.split().iterator().hasNext());
+
+            s.forEach(e -> {
+                l.add(e);
+            });
+        }
+        else {
+            int size = s.getSizeIfKnown();
+            for (int i = 0; i < s.getNaturalSplits(); i++) {
+                Spliterator<Integer> _s = s.split();
+                split(l, _s);
+            }
+
+            assertTrue(s.getSizeIfKnown() < size);
+
+            split(l, s);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/PrimitiveOpsTests.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.primitive.*;
+
+@Test
+public class PrimitiveOpsTests {
+
+    public void testSum() {
+        int sum = Primitives.range(1, 10).filter(i -> i % 2 == 0).sum();
+        Assert.assertEquals(sum, 20);
+    }
+
+    public void testMap() {
+        int sum = Primitives.range(1, 10).filter(i -> i % 2 == 0).map(i -> i * 2).sum();
+        Assert.assertEquals(sum, 40);
+    }
+
+    public void testParSum() {
+        int sum = Primitives.parRange(1, 10).filter(i -> i % 2 == 0).sum();
+        Assert.assertEquals(sum, 20);
+    }
+
+    public void testSumPull() {
+        IntStream s = Primitives.range(1, 10).filter(i -> i % 2 == 0);
+
+        IntIterator ii = s.iterator();
+        int i = ii.nextInt();
+
+        Assert.assertEquals(s.sum() + i, 20);
+    }
+
+    public void testTee() {
+        int[] teeSum = new int[1];
+        int sum = Primitives.range(1, 10).filter(i -> i % 2 == 0).tee(i -> { teeSum[0] = teeSum[0] + i; }).sum();
+        Assert.assertEquals(teeSum[0], sum);
+    }
+
+    public void testForEach() {
+        int[] sum = new int[1];
+        Primitives.range(1, 10).filter(i -> i % 2 == 0).forEach(i -> { sum[0] = sum[0] + i; });
+        Assert.assertEquals(sum[0], 20);
+    }
+
+    public void testParForEach() {
+        AtomicInteger ai = new AtomicInteger(0);
+        Primitives.parRange(1, 10).filter(i -> i % 2 == 0).forEach(i -> { ai.addAndGet(i); });
+        Assert.assertEquals(ai.get(), 20);
+    }
+
+    public void testBox() {
+        List<Integer> l = Primitives.parRange(1, 10).boxed().into(new ArrayList<Integer>());
+        int sum = l.stream().reduce(0, (a, b) -> a + b);
+        Assert.assertEquals(sum, 45);
+    }
+
+    public void testUnBox() {
+       int sum = Arrays.asList(1, 2, 3, 4, 5).stream().map(i -> (int) i).sum();
+        Assert.assertEquals(sum, 15);
+    }
+
+    public void testToArray() {
+        {
+            int[] array =  Primitives.range(1, 10).map(i -> i * 2).toArray();
+            Assert.assertEquals(array, new int[] {2, 4, 6, 8, 10, 12, 14, 16, 18});
+        }
+
+        {
+            int[] array =  Primitives.parRange(1, 10).map(i -> i * 2).toArray();
+            Assert.assertEquals(array, new int[] {2, 4, 6, 8, 10, 12, 14, 16, 18});
+        }
+    }
+
+    public void testSort() {
+        Random r = new Random();
+
+        int[] content = Primitives.repeatedly(10, () -> r.nextInt(100)).toArray();
+        int[] sortedContent = content.clone();
+        Arrays.sort(sortedContent);
+
+        {
+            int[] array =  Primitives.stream(content).sorted().toArray();
+            Assert.assertEquals(array, sortedContent);
+        }
+
+        {
+            int[] array =  Primitives.parallel(content).sorted().toArray();
+            Assert.assertEquals(array, sortedContent);
+        }
+    }
+
+    public void testSortSort() {
+        Random r = new Random();
+
+        int[] content = Primitives.repeatedly(10, () -> r.nextInt(100)).toArray();
+        int[] sortedContent = content.clone();
+        Arrays.sort(sortedContent);
+
+        {
+            int[] array =  Primitives.stream(content).sorted().sorted().toArray();
+            Assert.assertEquals(array, sortedContent);
+        }
+
+        {
+            int[] array =  Primitives.parallel(content).sorted().sorted().toArray();
+            Assert.assertEquals(array, sortedContent);
+        }
+    }
+
+    public void testSequential() {
+
+        int[] expected = Primitives.range(1, 1000).toArray();
+
+        {
+            IntNodeBuilder nb = IntNodes.makeVariableSizeBuilder();
+            Primitives.range(1, 1000).sequential().forEach(nb);
+            Assert.assertTrue(Arrays.equals(expected, nb.build().asIntArray()));
+        }
+
+        {
+            IntNodeBuilder nb = IntNodes.makeVariableSizeBuilder();
+            Primitives.parRange(1, 1000).sequential().forEach(nb);
+            Assert.assertTrue(Arrays.equals(expected, nb.build().asIntArray()));
+        }
+    }
+
+    public void testLimit() {
+        int[] expected = Primitives.range(1, 10).toArray();
+
+        {
+            int[] actual = Primitives.iterate(1, i -> i + 1).limit(9).toArray();
+            Assert.assertTrue(Arrays.equals(expected, actual));
+        }
+
+        {
+            int[] actual = Primitives.parRange(1, 100).limit(9).toArray();
+            Assert.assertTrue(Arrays.equals(expected, actual));
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ReduceByOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.function.Functions;
+import java.util.stream.op.GroupByOp;
+import java.util.stream.op.ReduceByOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * ReduceByOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class ReduceByOpTest extends OpTestCase {
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        Map<Boolean,Collection<Integer>> gbResult = data.stream().groupBy(Functions.forPredicate(pEven, true, false));
+        Map<Boolean,Integer> result = data.stream().reduceBy(Functions.forPredicate(pEven, true, false),
+                                                                () -> 0, rPlus, rPlus);
+        assertEquals(result.size(), gbResult.size());
+        for (Map.Entry<Boolean, Integer> entry : result.entrySet())
+            assertEquals(entry.getValue(), data.stream().filter(e -> pEven.test(e) == entry.getKey()).reduce(0, rPlus));
+
+        int uniqueSize = data.into(new HashSet<Integer>()).size();
+        Map<Integer, Collection<Integer>> mgResult = exerciseOps(data, new GroupByOp<>(mId));
+        Map<Integer, Integer> miResult = exerciseOps(data, new ReduceByOp<Integer, Integer, Integer>(mId, () -> 0, (w, t) -> w + 1, (w, u) -> w + u));
+        assertEquals(miResult.keySet().size(), uniqueSize);
+        for (Map.Entry<Integer, Integer> entry : miResult.entrySet())
+            assertEquals((int) entry.getValue(), mgResult.get(entry.getKey()).size());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ReduceTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.op.FilterOp;
+import java.util.stream.op.FoldOp;
+import java.util.stream.op.MapOp;
+import java.util.stream.op.SeedlessFoldOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * ReduceOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class ReduceTest extends OpTestCase {
+    public void testReduce() {
+        List<Integer> list = countTo(10);
+
+        assertEquals(55, (int) list.stream().reduce(rPlus).get());
+        assertEquals(55, (int) list.stream().reduce(0, rPlus));
+        assertEquals(10, (int) list.stream().reduce(rMax).get());
+        assertEquals(1, (int) list.stream().reduce(rMin).get());
+
+        assertEquals(0, (int) countTo(0).stream().reduce(0, rPlus));
+        assertTrue(!countTo(0).stream().reduce(rPlus).isPresent());
+
+        assertEquals(110, (int) list.stream().map(mDoubler).reduce(rPlus).get());
+        assertEquals(20, (int) list.stream().map(mDoubler).reduce(rMax).get());
+        assertEquals(2, (int) list.stream().map(mDoubler).reduce(rMin).get());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        assertEquals(0, (int) exerciseOps(data, new FoldOp<>(() -> 0, rPlus, rPlus), new FilterOp<>(pFalse)));
+
+        Optional<Integer> seedless = exerciseOps(data, new SeedlessFoldOp<>(rPlus));
+        Integer folded = exerciseOps(data, new FoldOp<>(() -> 0, rPlus, rPlus));
+        assertEquals(folded, seedless.orElse(0));
+
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rMin));
+        folded = exerciseOps(data, new FoldOp<>(() -> Integer.MAX_VALUE, rMin, rMin));
+        assertEquals(folded, seedless.orElse(Integer.MAX_VALUE));
+
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rMax));
+        folded = exerciseOps(data, new FoldOp<>(() -> Integer.MIN_VALUE, rMax, rMax));
+        assertEquals(folded, seedless.orElse(Integer.MIN_VALUE));
+
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rPlus), new MapOp<>(mDoubler));
+        folded = exerciseOps(data, new FoldOp<>(() -> 0, rPlus, rPlus), new MapOp<>(mDoubler));
+        assertEquals(folded, seedless.orElse(0));
+
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rMin), new MapOp<>(mDoubler));
+        folded = exerciseOps(data, new FoldOp<>(() -> Integer.MAX_VALUE, rMin, rMin), new MapOp<>(mDoubler));
+        assertEquals(folded, seedless.orElse(Integer.MAX_VALUE));
+
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rMax), new MapOp<>(mDoubler));
+        folded = exerciseOps(data, new FoldOp<>(() -> Integer.MIN_VALUE, rMax, rMax), new MapOp<>(mDoubler));
+        assertEquals(folded, seedless.orElse(Integer.MIN_VALUE));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/SliceOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+import java.util.function.UnaryOperator;
+import java.util.stream.AbstractPipeline;
+import java.util.stream.Stream;
+import java.util.stream.Streamable;
+import java.util.stream.op.Node;
+import java.util.stream.op.NodeBuilder;
+import java.util.stream.op.Nodes;
+import java.util.stream.op.SliceOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+import static org.openjdk.tests.java.util.LambdaTestHelpers.assertContents;
+import static org.openjdk.tests.java.util.LambdaTestHelpers.countTo;
+
+/**
+ * SliceOpTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class SliceOpTest extends OpTestCase {
+
+
+    public void testSkip() {
+        assertCountSum(countTo(0).stream().skip(0), 0, 0);
+        assertCountSum(countTo(0).stream().skip(4), 0, 0);
+        assertCountSum(countTo(4).stream().skip(4), 0, 0);
+        assertCountSum(countTo(4).stream().skip(2), 2, 7);
+        assertCountSum(countTo(4).stream().skip(0), 4, 10);
+
+        assertCountSum(countTo(0).parallel().skip(0), 0, 0);
+        assertCountSum(countTo(0).parallel().skip(4), 0, 0);
+        assertCountSum(countTo(4).parallel().skip(4), 0, 0);
+        assertCountSum(countTo(4).parallel().skip(2), 2, 7);
+        assertCountSum(countTo(4).parallel().skip(0), 4, 10);
+
+        exerciseOps(Collections.emptyList(), s -> s.skip(0), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.skip(10), Collections.emptyList());
+
+        exerciseOps(countTo(1), s -> s.skip(0), countTo(1));
+        exerciseOps(countTo(1), s -> s.skip(1), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(0), countTo(100));
+        exerciseOps(countTo(100), s -> s.skip(10), range(11, 100));
+        exerciseOps(countTo(100), s -> s.skip(100), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(200), Collections.<Integer>emptyList());
+    }
+
+    public void testLimit() {
+        assertCountSum(countTo(0).stream().limit(4), 0, 0);
+        assertCountSum(countTo(2).stream().limit(4), 2, 3);
+        assertCountSum(countTo(4).stream().limit(4), 4, 10);
+        assertCountSum(countTo(8).stream().limit(4), 4, 10);
+
+        assertCountSum(countTo(0).parallel().limit(4), 0, 0);
+        assertCountSum(countTo(2).parallel().limit(4), 2, 3);
+        assertCountSum(countTo(4).parallel().limit(4), 4, 10);
+        assertCountSum(countTo(8).parallel().limit(4), 4, 10);
+
+        exerciseOps(Collections.emptyList(), s -> s.limit(0), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.limit(10), Collections.emptyList());
+        exerciseOps(countTo(1), s -> s.limit(0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(1), s -> s.limit(1), countTo(1));
+        exerciseOps(countTo(100), s -> s.limit(0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.limit(10), countTo(10));
+        exerciseOps(countTo(100), s -> s.limit(10).limit(10), countTo(10));
+        exerciseOps(countTo(100), s -> s.limit(100), countTo(100));
+        exerciseOps(countTo(100), s -> s.limit(100).limit(10), countTo(10));
+        exerciseOps(countTo(100), s -> s.limit(200), countTo(100));
+    }
+
+    public void testSkipLimit() {
+        exerciseOps(Collections.emptyList(), s -> s.skip(0).limit(0), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.skip(0).limit(10), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.skip(10).limit(0), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.skip(10).limit(10), Collections.emptyList());
+
+        exerciseOps(countTo(100), s -> s.skip(0).limit(100), countTo(100));
+        exerciseOps(countTo(100), s -> s.skip(0).limit(10), countTo(10));
+        exerciseOps(countTo(100), s -> s.skip(0).limit(0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(10).limit(100), range(11, 100));
+        exerciseOps(countTo(100), s -> s.skip(10).limit(10), range(11, 20));
+        exerciseOps(countTo(100), s -> s.skip(10).limit(0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(100).limit(100), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(100).limit(10), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(100).limit(0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(200).limit(100), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(200).limit(10), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.skip(200).limit(0), Collections.<Integer>emptyList());
+    }
+
+    public void testSlice() {
+        exerciseOps(Collections.emptyList(), s -> s.slice(0, 0), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.slice(0, 10), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.slice(10, 0), Collections.emptyList());
+        exerciseOps(Collections.emptyList(), s -> s.slice(10, 10), Collections.emptyList());
+
+        exerciseOps(countTo(100), s -> s.slice(0, 100), countTo(100));
+        exerciseOps(countTo(100), s -> s.slice(0, 10), countTo(10));
+        exerciseOps(countTo(100), s -> s.slice(0, 0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(10, 100), range(11, 100));
+        exerciseOps(countTo(100), s -> s.slice(10, 10), range(11, 20));
+        exerciseOps(countTo(100), s -> s.slice(10, 0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(100, 100), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(100, 10), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(100, 0), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(200, 100), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(200, 10), Collections.<Integer>emptyList());
+        exerciseOps(countTo(100), s -> s.slice(200, 0), Collections.<Integer>emptyList());
+    }
+
+    private int sliceSize(int dataSize, int skip, int limit) {
+        int size = Math.max(0, dataSize - skip);
+        if (limit >= 0)
+            size = Math.min(size, limit);
+        return size;
+    }
+
+    private int sliceSize(int dataSize, int skip) {
+        return Math.max(0, dataSize - skip);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testSkipOps(String name, StreamTestData<Integer> data) {
+        List<Integer> skips = Collections.unmodifiableList(sizes(data));
+
+        for (int s : skips) {
+            Node<Integer> sr = exerciseOps(data, st -> st.skip(s));
+            assertEquals(sr.size(), sliceSize(data.size(), s));
+
+            sr = exerciseOps(data, st -> st.skip(s).skip(s / 2));
+            assertEquals(sr.size(), sliceSize(sliceSize(data.size(), s), s/2));
+        }
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testSkipLimitOps(String name, StreamTestData<Integer> data) {
+        List<Integer> skips = Collections.unmodifiableList(sizes(data));
+        List<Integer> limits = Collections.unmodifiableList(sizes(data));
+
+        for (int s : skips) {
+            for (int limit : limits) {
+                Node<Integer> sr = exerciseOps(data, st -> st.skip(s).limit(limit));
+                assertEquals(sr.size(), sliceSize(sliceSize(data.size(), s), 0, limit));
+
+                sr = exerciseOps(data, st -> st.slice(s, limit));
+                assertEquals(sr.size(), sliceSize(data.size(), s, limit));
+            }
+        }
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testLimitOps(String name, StreamTestData<Integer> data) {
+        List<Integer> limits = Collections.unmodifiableList(sizes(data));
+
+        for (int limit : limits) {
+            Node<Integer> sr = null;
+            sr = exerciseOps(data, st -> st.limit(limit));
+            assertEquals(sr.size(), sliceSize(data.size(), 0, limit));
+
+            sr = exerciseOps(data, st -> st.limit(limit).limit(limit / 2));
+            assertEquals(sr.size(), sliceSize(sliceSize(data.size(), 0, limit), 0, limit/2));
+        }
+    }
+
+    public void testLimitShortCircuit() {
+        for (int l : Arrays.asList(0, 10)) {
+            AtomicInteger ai = new AtomicInteger();
+            countTo(100).stream()
+                    .tee(i -> { ai.getAndIncrement(); })
+                    .limit(l).toArray();
+            assertEquals(ai.get(), l, "tee block was called too many times");
+        }
+    }
+
+    public void testSkipParallel() {
+        List<Integer> l = countTo(1000).parallel().skip(200).limit(200).sequential().into(new ArrayList<Integer>());
+        assertEquals(l.size(), 200);
+        assertEquals(l.get(l.size() -1).intValue(), 400);
+    }
+
+    public void testLimitParallel() {
+        List<Integer> l = countTo(1000).parallel().limit(500).sequential().into(new ArrayList<Integer>());
+        assertEquals(l.size(), 500);
+        assertEquals(l.get(l.size() -1).intValue(), 500);
+    }
+
+    private List<Integer> sizes(StreamTestData<?> data) {
+        int size = data.size();
+        if (size < 4) {
+            return Arrays.asList(0, 1, 2, 3, 4, 6);
+        }
+        else {
+            return Arrays.asList(0, 1, size / 2, size - 1, size, size + 1, 2 * size);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/SortedOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.Comparators;
+import java.util.List;
+import java.util.stream.ParallelPipelineHelper;
+import java.util.stream.StreamOpFlags;
+import java.util.stream.op.CollectorOps;
+import java.util.stream.op.Node;
+import java.util.stream.op.SortedOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * SortedOpTest
+ *
+ * @author Brian Goetz
+ */
+public class SortedOpTest extends OpTestCase {
+    public void testRawIterator() {
+        assertCountSum(SortedOp.iterator(countTo(0).iterator(), cInteger), 0, 0);
+        assertCountSum(SortedOp.iterator(countTo(10).iterator(), cInteger), 10, 55);
+        assertCountSum(SortedOp.iterator(countTo(10).iterator(), cInteger.reverse()), 10, 55);
+
+        assertSorted(SortedOp.iterator(countTo(10).iterator(), cInteger));
+    }
+
+    public void testSorted() {
+        assertCountSum(countTo(0).stream().sorted(cInteger), 0, 0);
+        assertCountSum(countTo(10).stream().sorted(cInteger), 10, 55);
+        assertCountSum(countTo(10).stream().sorted(cInteger.reverse()), 10, 55);
+
+        List<Integer> to10 = countTo(10);
+        Collections.reverse(to10);
+        assertSorted(to10.stream().sorted(cInteger).iterator());
+    }
+
+    public void testSortedComparable() {
+        List<Integer> list = countTo(100);
+        assertSorted(list);
+        assertSorted(SortedOp.iterator(list.iterator(), Comparators.<Integer>naturalOrder()));
+        Collections.reverse(list);
+        assertSorted(SortedOp.iterator(list.iterator(), Comparators.<Integer>naturalOrder()));
+
+        // empty iterator
+        assertTrue(!SortedOp.iterator(countTo(0).iterator(), Comparators.<Integer>naturalOrder()).hasNext());
+
+        // constant iterator
+        list.clear();
+        for (int i = 0; i < 100; i++)
+            list.add(1);
+        assertSorted(list);
+        assertSorted(SortedOp.iterator(list.iterator(), Comparators.<Integer>naturalOrder()));
+        Collections.reverse(list);
+        assertSorted(SortedOp.iterator(list.iterator(), Comparators.<Integer>naturalOrder()));
+    }
+
+    public void testSortedComparator() {
+        List<Integer> list = countTo(100);
+        assertSorted(list);
+        assertSorted(SortedOp.iterator(list.iterator(), cInteger));
+        Collections.reverse(list);
+        assertSorted(SortedOp.iterator(list.iterator(), cInteger));
+
+        // empty iterator
+        assertTrue(!SortedOp.iterator(countTo(0).iterator(), cInteger).hasNext());
+
+        // constant iterator
+        list.clear();
+        for (int i = 0; i < 100; i++)
+            list.add(1);
+        assertSorted(list, cInteger);
+        assertSorted(SortedOp.iterator(list.iterator(), cInteger));
+        Collections.reverse(list);
+        assertSorted(SortedOp.iterator(list.iterator(), cInteger));
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        SortedOp<Integer> op = new SortedOp<>(cInteger);
+
+        Node<Integer> result = exerciseOps(data, op);
+        assertSorted(result.iterator());
+        // @@@ Can make stronger assertions about content equality
+        Assert.assertEquals(result.size(), data.size());
+
+        result = exerciseOps(data, new SortedOp<>(cInteger.reverse()));
+        Assert.assertEquals(result.size(), data.size());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testSortSort(String name, StreamTestData<Integer> data) {
+        SortedOp<Integer> op = new SortedOp<>(cInteger);
+
+        // For parallel cases ensure the 
+        Node<Integer> result = exerciseOps(data, op, op, new TestParallelSizedOp<>());
+        assertSorted(result.iterator());
+        Assert.assertEquals(result.size(), data.size());
+    }
+
+    private static class TestParallelSizedOp<T> extends CollectorOps.Parallel<T> {
+        @Override
+        public <P_IN> Node<T> evaluateParallel(ParallelPipelineHelper<P_IN, T> helper) {
+            int flags = helper.getStreamFlags();
+
+            assertTrue(StreamOpFlags.SIZED.isKnown(flags));
+            return super.evaluateParallel(helper);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/TeeOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterators;
+import java.util.List;
+import java.util.function.Block;
+import java.util.stream.Stream;
+import java.util.stream.op.TeeOp;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * TeeOpTest
+ */
+public class TeeOpTest extends OpTestCase {
+    private <T> Block<T> asBlock(List<T> l) {
+        return t -> {
+            l.add(t);
+        };
+    }
+
+    public void testRawIterator() {
+        List<Integer> copy = new ArrayList<>();
+
+        assertCountSum(TeeOp.iterator(countTo(0).iterator(), asBlock(copy)), 0, 0);
+        assertCountSum(copy.iterator(), 0, 0);
+
+        copy.clear();
+        assertCountSum(TeeOp.iterator(countTo(10).iterator(), asBlock(copy)), 10, 55);
+        assertCountSum(copy.iterator(), 10, 55);
+
+        copy.clear();
+        assertCountSum(TeeOp.iterator(Iterators.map(countTo(10).iterator(), mDoubler), asBlock(copy)), 10, 110);
+        assertCountSum(copy.iterator(), 10, 110);
+    }
+
+    public void testTee() {
+        List<Integer> copy = new ArrayList<>();
+
+        assertCountSum(countTo(0).stream().tee(asBlock(copy)), 0, 0);
+        assertCountSum(copy.iterator(), 0, 0);
+
+        copy.clear();
+        assertCountSum(countTo(10).stream().tee(asBlock(copy)), 10, 55);
+        assertCountSum(copy.iterator(), 10, 55);
+
+        copy.clear();
+        assertCountSum(countTo(10).stream().map(mDoubler).tee(asBlock(copy)), 10, 110);
+        assertCountSum(copy.iterator(), 10, 110);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, final StreamTestData<Integer> data) {
+        class RecordingBlock implements Block<Integer> {
+            List<Integer> list;
+
+            void before(TestData<Integer, Stream<Integer>> td) {
+                // Tee block can be called concurrently
+                list = Collections.<Integer>synchronizedList(new ArrayList<>());
+            }
+
+            public void apply(Integer t) {
+                list.add(t);
+            }
+
+            void after(TestData<Integer, Stream<Integer>> td) {
+                // No guarantees in parallel tests that calls to tee block will
+                // be in the encounter order, if defined, of the data
+                assertContentsUnordered(list, data.into(new ArrayList<Integer>()));
+            }
+        }
+
+        final RecordingBlock b = new RecordingBlock();
+
+        withData(data).
+                using(new TeeOp<>(b)).
+                before(b::before).
+                after(b::after).
+                exercise();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/TestFlagExpectedOp.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,76 @@
+package org.openjdk.tests.java.util.stream.op;/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import org.testng.Assert;
+
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.stream.Sink;
+import java.util.stream.StreamOpFlags;
+import java.util.stream.op.FlagDeclaringOp;
+
+class TestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
+    final EnumSet<StreamOpFlags> known;
+    final EnumSet<StreamOpFlags> preserve;
+    final EnumSet<StreamOpFlags> notKnown;
+
+    TestFlagExpectedOp(int flags, EnumSet<StreamOpFlags> known) {
+        this(flags, known, EnumSet.noneOf(StreamOpFlags.class), EnumSet.noneOf(StreamOpFlags.class));
+    }
+
+    TestFlagExpectedOp(int flags, EnumSet<StreamOpFlags> known, EnumSet<StreamOpFlags> preserve, EnumSet<StreamOpFlags> notKnown) {
+        super(flags);
+        this.known = known;
+        this.preserve = preserve;
+        this.notKnown = notKnown;
+    }
+
+    @Override
+    public Iterator<T> wrapIterator(int flags, Iterator<T> downstream) {
+        assertFlags(flags);
+        return downstream;
+    }
+
+    @Override
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public Sink<T> wrapSink(int flags, Sink upstream) {
+        assertFlags(flags);
+        return upstream;
+    }
+
+    private void assertFlags(int flags) {
+        for (StreamOpFlags f : known) {
+            Assert.assertTrue(f.isKnown(flags), String.format("Flag %s is not known, but should be known.", f.toString()));
+        }
+
+        for (StreamOpFlags f : preserve) {
+            Assert.assertTrue(f.isPreserve(flags), String.format("Flag %s is not preserved, but should be preserved.", f.toString()));
+        }
+
+        for (StreamOpFlags f : notKnown) {
+            Assert.assertFalse(f.isKnown(flags), String.format("Flag %s is known, but should be not known.", f.toString()));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ToArrayOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.StreamOpFlags;
+import java.util.stream.Streams;
+import java.util.stream.op.*;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+
+/**
+ * ToArrayOpTest
+ *
+ */
+@Test
+public class ToArrayOpTest extends OpTestCase {
+
+    public void testToArray() {
+        assertCountSum(Arrays.asList(countTo(0).stream().toArray()), 0, 0);
+        assertCountSum(Arrays.asList(countTo(10).stream().toArray()), 10, 55);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOps(String name, StreamTestData<Integer> data) {
+        exerciseOps(data, Arrays::equals, ToArrayOp.<Integer>singleton());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsWithMap(String name, StreamTestData<Integer> data) {
+        // Retain the size of the source
+        // This should kick in the parallel evaluation optimization for tasks stuffing elements into a shared array
+        Object[] objects = exerciseOps(data, Arrays::equals, ToArrayOp.<Integer>singleton(),
+                                       new MapOp<Integer, Integer>(i -> i + i));
+        assertTrue(objects.length == data.size());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsWithFlatMap(String name, StreamTestData<Integer> data) {
+        // Double the size of the source
+        Object[] objects = exerciseOps(data, Arrays::equals, ToArrayOp.<Integer>singleton(),
+                                       new FlatMapOp<Integer, Integer>((s, e) -> {
+                                           s.apply(e);
+                                           s.apply(e);
+                                       }));
+        assertTrue(objects.length == data.size() * 2);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsWithSorted(String name, StreamTestData<Integer> data) {
+        // Retain the size of the source
+        // This should kick in the parallel evaluation optimization for tasks stuffing elements into a shared array
+        Object[] objects = exerciseOps(data, Arrays::equals, ToArrayOp.<Integer>singleton(),
+                                       new SortedOp<Integer>());
+        assertTrue(objects.length == data.size());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpsWithCumulate(String name, StreamTestData<Integer> data) {
+        // Retain the size of the source
+        // This should kick in the parallel evaluation optimization for tasks stuffing elements into a shared array
+        Object[] objects = exerciseOps(data, Arrays::equals, ToArrayOp.<Integer>singleton(),
+                                       new CumulateOp<Integer>(rPlus));
+        assertTrue(objects.length == data.size());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testWithNode(String name, StreamTestData<Integer> data) {
+        List<Integer> l = new ArrayList<>();
+        for (Integer i : data) {
+            l.add(i);
+        }
+
+        {
+            Node<Integer> node = Nodes.node(l);
+            Object[] output = Streams.stream(node, StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED).toArray();
+            assertEquals(Arrays.asList(output), l);
+        }
+
+        {
+            Node<Integer> node = Nodes.node(l.toArray(new Integer[l.size()]));
+            Object[] output = Streams.stream(node, StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED).toArray();
+            assertEquals(Arrays.asList(output), l);
+        }
+
+        {
+            Node<Integer> node = tree(l);
+            Object[] output = Streams.stream(node, StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED).toArray();
+            assertEquals(Arrays.asList(output), l);
+        }
+
+        {
+            NodeBuilder<Integer> nodeBuilder = Nodes.makeBuilder(l.size());
+            for (Integer i : l) {
+                nodeBuilder.apply(i);
+            }
+            Object[] output = Streams.stream(nodeBuilder, StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED).toArray();
+            assertEquals(Arrays.asList(output), l);
+        }
+
+        {
+            NodeBuilder<Integer> nodeBuilder = Nodes.makeVariableSizeBuilder();
+            nodeBuilder.begin(l.size());
+            for (Integer i : l) {
+                nodeBuilder.apply(i);
+            }
+            nodeBuilder.end();
+            Object[] output = Streams.stream(nodeBuilder, StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED).toArray();
+            assertEquals(Arrays.asList(output), l);
+        }
+
+        {
+            Node<Integer> node = Nodes.node(l);
+            Object[] output = Streams.stream(node, StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED).sequential().toArray();
+            assertEquals(Arrays.asList(output), l);
+        }
+
+    }
+
+    Node<Integer> tree(List<Integer> l) {
+        if (l.size() < 3) {
+            return Nodes.node(l.toArray(new Integer[l.size()]));
+        }
+        else {
+            return Nodes.node(tree(l.subList(0, l.size() / 2)), tree(l.subList(l.size() / 2, l.size())));
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/UniqOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.openjdk.tests.java.util.LambdaTestHelpers;
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.openjdk.tests.java.util.stream.StreamTestData;
+import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
+import org.testng.annotations.Test;
+
+import java.util.stream.ParallelPipelineHelper;
+import java.util.stream.Stream;
+import java.util.stream.StreamOpFlags;
+import java.util.stream.op.*;
+
+import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
+
+/**
+ * UniqOpTest
+ *
+ */
+@Test
+public class UniqOpTest extends OpTestCase {
+
+    public void testUniqOp() {
+        assertCountSum(repeat(0, 10).stream().uniqueElements(), 1 , 0);
+        assertCountSum(repeat(1, 10).stream().uniqueElements(), 1 , 1);
+        assertCountSum(countTo(0).stream().uniqueElements(), 0, 0);
+        assertCountSum(countTo(10).stream().uniqueElements(), 10, 55);
+        assertCountSum(countTo(10).stream().uniqueElements(), 10, 55);
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOp(String name, StreamTestData<Integer> data) {
+        Node<Integer> result = exerciseOps(data, s -> s.uniqueElements());
+
+        assertUnique(result);
+        if (data.size() > 0)
+            assertTrue(result.size() > 0);
+        else
+            assertTrue(result.size() == 0);
+        assertTrue(result.size() <= data.size());
+    }
+
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testOpUnordered(String name, StreamTestData<Integer> data) {
+        Node<Integer> result = withData(data).
+                using(s -> s.unordered().uniqueElements()).
+                parallelEqualator(LambdaTestHelpers::equalsContentsUnordered).
+                exercise();
+
+        assertUnique(result);
+        if (data.size() > 0)
+            assertTrue(result.size() > 0);
+        else
+            assertTrue(result.size() == 0);
+        assertTrue(result.size() <= data.size());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testUniqUniq(String name, StreamTestData<Integer> data) {
+        exerciseOps(data,
+                    UniqOp.singleton(), UniqOp.singleton(), new TestParallelSizedOp<>());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testUniqSort(String name, StreamTestData<Integer> data) {
+        exerciseOps(data,
+                    UniqOp.singleton(), new SortedOp<>(), new TestParallelSizedOp<>());
+    }
+
+    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
+    public void testSortUniq(String name, StreamTestData<Integer> data) {
+        exerciseOps(data,
+                    new SortedOp<>(), UniqOp.singleton(), new TestParallelSizedOp<>());
+    }
+
+    private static class TestParallelSizedOp<T> extends CollectorOps.Parallel<T> {
+        @Override
+        public <P_IN> Node<T> evaluateParallel(ParallelPipelineHelper<P_IN, T> helper) {
+            int flags = helper.getStreamFlags();
+
+            assertTrue(StreamOpFlags.SIZED.isKnown(flags));
+            return super.evaluateParallel(helper);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/UnorderedStreamTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.op;
+
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.stream.AbstractPipeline;
+import java.util.stream.ReferencePipeline;
+import java.util.stream.Stream;
+import java.util.stream.StreamOpFlags;
+
+@Test
+public class UnorderedStreamTest {
+
+    public void testUnordered() {
+        testUnordered(Arrays.asList(1, 2, 3).stream());
+        testUnordered(Arrays.asList(1, 2, 3).parallel());
+    }
+
+    <T> void testUnordered(Stream<T> s) {
+        s = s.unordered();
+
+        @SuppressWarnings("unchecked")
+        Stream<Integer> st = new ReferencePipeline<Integer, Integer>(
+                (AbstractPipeline<Integer, Integer>) s,
+                new TestFlagExpectedOp<>(0,
+                                         EnumSet.noneOf(StreamOpFlags.class),
+                                         EnumSet.noneOf(StreamOpFlags.class),
+                                         EnumSet.of(StreamOpFlags.ORDERED)));
+        st.toArray();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntFilterOpTest.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.primitive;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+import org.testng.annotations.Test;
+
+import java.util.stream.op.Node;
+import java.util.stream.primitive.IntFilterOp;
+
+@Test
+public class IntFilterOpTest extends OpTestCase {
+
+    @Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
+    public void testOps(String name, IntStreamTestData data) {
+        Node<Integer> result = exerciseOps(data, new IntFilterOp(i -> true));
+        assertEquals(result.size(), data.size());
+
+        result = exerciseOps(data, new IntFilterOp(i -> false));
+        assertEquals(result.size(), 0);
+
+        exerciseOps(data, new IntFilterOp(i -> 0 == i % 2));
+        exerciseOps(data, new IntFilterOp(i -> 1 == i % 2));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamIntermediateOpTestScenario.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.primitive;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+
+import java.util.Iterator;
+import java.util.function.Block;
+import java.util.function.Function;
+import java.util.stream.*;
+import java.util.stream.op.FlagDeclaringOp;
+import java.util.stream.op.IntermediateOp;
+import java.util.stream.primitive.IntBlock;
+import java.util.stream.primitive.IntIterator;
+import java.util.stream.primitive.IntStream;
+import java.util.stream.primitive.Primitives;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum IntStreamIntermediateOpTestScenario implements OpTestCase.IntermediateOpTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            m.apply(data.stream()).forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            for (int t : m.apply(data.stream()).toArray()) {
+                b.applyInt(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            for (IntIterator seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
+                b.applyInt(seqIter.nextInt());
+        }
+    },
+
+    STREAM_MIXED(false) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            IntStream stream = m.apply(data.stream());
+            IntIterator iter = stream.iterator();
+            if (iter.hasNext())
+                b.applyInt(iter.nextInt());
+            stream.forEach(b);
+        }
+    },
+
+    STREAM_MIXED_ITERATOR_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            AbstractPipeline<?, ?> pipe1 = data.seq(new NoOp(data.getShape()));
+            IntStream pipe2 = m.apply((S_IN) pipe1);
+
+            pipe1.iterator();
+            pipe2.forEach(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            m.apply(data.parallel()).sequential().forEach(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            for (int t : m.apply(data.parallel()).toArray())
+                b.applyInt(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            AbstractPipeline<?, ?> pipe1 = data.par(new FlagDeclaringOp(StreamOpFlags.NOT_SIZED) {
+                @Override
+                public StreamShape outputShape() {
+                    return data.getShape();
+                }
+
+                @Override
+                public StreamShape inputShape() {
+                    return data.getShape();
+                }
+            });
+            IntStream pipe2 = m.apply((S_IN) pipe1);
+
+            for (int t : pipe2.toArray())
+                b.applyInt(t);
+        }
+    },
+
+    PAR_STREAM_ITERATOR_TO_ARRAY_MIXED(true) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            IntStream stream = m.apply(data.parallel());
+            IntIterator iter = stream.iterator();
+            if (iter.hasNext())
+                b.applyInt(iter.nextInt());
+            for (int t : stream.toArray())
+                b.applyInt(t);
+        }
+    },
+
+    PAR_STREAM_MIXED_ITERATOR_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            AbstractPipeline<?, ?> pipe1 = data.par(new NoOp(data.getShape()));
+            IntStream pipe2 = m.apply((S_IN) pipe1);
+
+            pipe1.iterator();
+            for (int t : pipe2.toArray())
+                b.applyInt(t);
+        }
+    },
+
+    // Wrap as parallel stream, and iterate in mixed mode
+    PAR_STREAM_SEQUENTIAL_MIXED(true) {
+        <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m) {
+            IntStream stream = m.apply(data.parallel());
+            IntIterator iter = stream.iterator();
+            if (iter.hasNext())
+                b.applyInt(iter.nextInt());
+            stream.sequential().forEach(b);
+        }
+    },
+
+    ;
+
+    private static class NoOp<T> implements IntermediateOp<T, T> {
+
+        private final StreamShape shape;
+
+        private NoOp(StreamShape shape) {
+            this.shape = shape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return shape;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return shape;
+        }
+
+        @Override
+        public Iterator<T> wrapIterator(int flags, Iterator<T> in) {
+            return in;
+        }
+
+        @Override
+        public Sink<T> wrapSink(int flags, Sink<T> sink) {
+            return sink;
+        }
+    }
+
+    private boolean isParallel;
+
+    IntStreamIntermediateOpTestScenario(boolean isParallel) {
+        this.isParallel = isParallel;
+    }
+
+    public StreamShape getShape() {
+        return StreamShapeFactory.INT_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> void run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<S_OUT, S_IN> m) {
+        _run(data, (IntBlock) b, (Function<IntStream, S_IN>) m);
+    }
+
+    abstract <T, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, IntBlock b, Function<IntStream, S_IN> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestData.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.primitive;
+
+import org.openjdk.tests.java.util.stream.OpTestCase;
+
+import java.util.stream.AbstractPipeline;
+import java.util.stream.Stream;
+import java.util.stream.StreamShape;
+import java.util.stream.StreamShapeFactory;
+import java.util.stream.primitive.IntIterator;
+import java.util.stream.primitive.IntSpliterator;
+import java.util.stream.primitive.IntStream;
+import java.util.stream.primitive.Primitives;
+
+public abstract class IntStreamTestData implements OpTestCase.TestData<Integer, IntStream> {
+
+    @Override
+    @SuppressWarnings("rawtypes")
+    public StreamShape getShape() {
+        return StreamShapeFactory.INT_VALUE;
+    }
+
+    public static class ArrayData extends IntStreamTestData {
+        private final String name;
+        private final int[] array;
+
+        public ArrayData(String name, int[] array) {
+            this.name = name;
+            this.array = array;
+        }
+
+        @Override
+        public IntStream stream() {
+            return Primitives.stream(array);
+        }
+
+        @Override
+        public IntStream parallel() {
+            return Primitives.parallel(array);
+        }
+
+        @Override
+        public IntIterator iterator() {
+            return Primitives.iterator(array);
+        }
+
+        @Override
+        public IntSpliterator spliterator() {
+            return Primitives.spliterator(array);
+        }
+
+        @Override
+        public int size() {
+            return array.length;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/primitive/IntStreamTestDataProvider.java	Fri Nov 16 10:49:00 2012 +0100
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.tests.java.util.stream.primitive;
+
+import org.openjdk.tests.java.util.LambdaTestHelpers;
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.function.Combiner;
+
+public class IntStreamTestDataProvider {
+    private static final int[] to0 = new int[0];
+    private static final int[] to1 = new int[1];
+    private static final int[] to10 = new int[10];
+    private static final int[] to100 = new int[100];
+    private static final int[] to1000 = new int[1000];
+    private static final int[] reversed = new int[100];
+    private static final int[] ones = new int[100];
+    private static final int[] twice = new int[200];
+    private static final int[] pseudoRandom;
+
+    private static final Object[][] testData;
+
+    static {
+        int[][] arrays = {to0, to1, to10, to100, to1000};
+        for (int[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        List<Object[]> list = new ArrayList<>();
+        for (Object[] data : arrays) {
+            final Object name = data[0];
+            final int[] ints = (int[])data[1];
+
+            list.add(e("array:" + name, ints, IntStreamTestData.ArrayData::new));
+        }
+        testData = list.toArray(new Object[0][]);
+    }
+
+    static <T> Object[] e(String description, int[] data, Combiner<IntStreamTestData, String, int[]> m) {
+        return new Object[] { description, m.combine(description, data) };
+    }
+
+    // Return an array of ( String name, IntTestData<Integer> )
+    @DataProvider(name = "IntStreamTestData")
+    public static Object[][] makeValueTestData() {
+        return testData;
+    }
+}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/CollectionModifyStreamTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream;
-
-import org.openjdk.tests.java.util.LambdaTestHelpers;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.util.*;
-import java.util.stream.Stream;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-@Test
-public class CollectionModifyStreamTest {
-
-    @DataProvider(name = "collections")
-    public Object[][] createCollections() {
-        List<Integer> content = LambdaTestHelpers.countTo(10);
-
-        List<Collection<Integer>> collections = new ArrayList<>();
-        collections.add(new ArrayList<>(content));
-        collections.add(new LinkedList<>(content));
-        collections.add(new Vector<>(content));
-
-        collections.add(new HashSet<>(content));
-        collections.add(new LinkedHashSet<>(content));
-        collections.add(new TreeSet<>(content));
-
-        Stack<Integer> stack = new Stack<>();
-        stack.addAll(content);
-        collections.add(stack);
-        collections.add(new PriorityQueue<>(content));
-        collections.add(new ArrayDeque<>(content));
-
-        // Concurrent collections
-
-        Object[][] params = new Object[collections.size()][];
-        for (int i = 0; i < collections.size(); i++) {
-            params[i] = new Object[]{collections.get(i).getClass().getName(), collections.get(i)};
-        }
-
-        return params;
-    }
-
-    @Test(dataProvider = "collections")
-    public void testSizeRemove(String name, Collection<Integer> c) {
-        assertTrue(c.remove((Object) Integer.valueOf(1)));
-        Stream<Integer> s = c.stream();
-        assertTrue(c.remove((Object) Integer.valueOf(2)));
-        Object[] result = s.toArray();
-        assertEquals(result.length, c.size());
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/OpTestCase.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,455 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream;
-
-import org.openjdk.tests.java.util.LambdaTestHelpers;
-import org.openjdk.tests.java.util.stream.primitive.IntStreamIntermediateOpTestScenario;
-import org.testng.Assert;
-import org.testng.ITestContext;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.*;
-import java.util.function.BiPredicate;
-import java.util.function.Block;
-import java.util.function.Supplier;
-import java.util.function.Function;
-import java.util.stream.*;
-import java.util.stream.op.*;
-import java.util.stream.primitive.IntStream;
-
-/**
- * StreamOpTestCase
- *
- * @author Brian Goetz
- */
-@Test
-public abstract class OpTestCase extends Assert {
-
-    @SuppressWarnings("rawtypes")
-    private final Map<Class, Set<? extends IntermediateOpTestScenario>> testScenarios;
-
-    protected OpTestCase() {
-        // @@@ This only needs to be done once, consider using injection or an attribute on ITestContext
-        testScenarios = new HashMap<>();
-        testScenarios.put(Stream.class, Collections.unmodifiableSet(EnumSet.allOf(StreamIntermediateOpTestScenario.class)));
-        testScenarios.put(IntStream.class, Collections.unmodifiableSet(EnumSet.allOf(IntStreamIntermediateOpTestScenario.class)));
-    }
-
-    // Exercise intermediate operations
-
-    @SuppressWarnings("rawtypes")
-    public interface IntermediateOpTestScenario {
-        StreamShape getShape();
-
-        boolean isParallel();
-
-        abstract <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> void run(TestData<T, S_IN> data, Block<U> b, Function<S_OUT, S_IN> m);
-    }
-
-    @SuppressWarnings("unchecked")
-    public <T, U, S_IN extends BaseStream<T>> Node<U> exerciseOps(TestData<T, S_IN> data, IntermediateOp... ops) {
-        return (Node<U>) withData(data).
-                using(ops).
-                exercise();
-    }
-
-    public <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> Node<U> exerciseOps(TestData<T, S_IN> data, Function<S_OUT, S_IN> m) {
-        return withData(data).
-                using(m).
-                exercise();
-    }
-
-    public <T, U, S_OUT extends BaseStream<U>> Node<U> exerciseOps(Collection<T> data, Function<S_OUT, Stream<T>> m) {
-        return withData(new StreamTestData.CollectionData<>("Collection of type " + data.getClass().getName(), data)).
-                using(m).
-                exercise();
-    }
-
-    public <T, U, S_OUT extends BaseStream<U>, I extends Iterable<U> & Sized> Node<U> exerciseOps(Collection<T> data, Function<S_OUT, Stream<T>> m, I expected) {
-        return withData(new StreamTestData.CollectionData<>("Collection of type " + data.getClass().getName(), data)).
-                using(m).
-                expectedResult(expected).
-                exercise();
-    }
-
-    public <T, S_IN extends BaseStream<T>> IntermediateOpDataBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
-        Objects.requireNonNull(data);
-        return new IntermediateOpDataBuilder<>(data);
-    }
-
-    @SuppressWarnings("rawtypes")
-    public class IntermediateOpDataBuilder<T, S_IN extends BaseStream<T>> {
-        final TestData<T, S_IN> data;
-
-        private IntermediateOpDataBuilder(TestData<T, S_IN> data) {
-            this.data = Objects.requireNonNull(data);
-        }
-
-        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> using(IntermediateOp... ops) {
-            return usingOpsFactory(() -> ops);
-        }
-
-        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> usingOpFactory(Supplier<IntermediateOp> fop) {
-            return usingOpsFactory(() -> new IntermediateOp[] { fop.get() });
-        }
-
-        @SuppressWarnings("unchecked")
-        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> usingOpsFactory(Supplier<IntermediateOp[]> fops) {
-            return using((S_IN s) -> (S_OUT) chain((AbstractPipeline<?, T>)s, fops.get()));
-        }
-
-        public <U, S_OUT extends BaseStream<U>> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> using(Function<S_OUT, S_IN> m) {
-            return new IntermediateOpTestBuilder<>(data, m);
-        }
-
-    }
-
-    @SuppressWarnings("rawtypes")
-    public class IntermediateOpTestBuilder<T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> {
-        final TestData<T, S_IN> data;
-
-        final Function<S_OUT, S_IN> m;
-
-        final StreamShape shape;
-
-        Set<IntermediateOpTestScenario> testSet = new HashSet<>();
-
-        Node<U> refResult;
-
-        @SuppressWarnings("unchecked")
-        Block<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
-
-        @SuppressWarnings("unchecked")
-        Block<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
-
-        BiPredicate<Iterable<U>, Iterable<U>> sequentialEqualator = Objects::equals;
-
-        BiPredicate<Iterable<U>, Iterable<U>> parallelEqualator = Objects::equals;
-
-        private IntermediateOpTestBuilder(TestData<T, S_IN> data, Function<S_OUT, S_IN> m) {
-            this.data = data;
-
-            this.m = Objects.requireNonNull(m);
-
-            this.shape = ((AbstractPipeline<?, U>) m.apply(data.stream())).getOutputShape();
-
-            // Have to initiate from the output shape of the last stream
-            // This means the stream mapper is required first rather than last
-            testSet.addAll(testScenarios.get(shape.getStreamType()));
-        }
-
-        public BiPredicate<Iterable<U>, Iterable<U>> getEqualator(IntermediateOpTestScenario t) {
-            return t.isParallel() ? parallelEqualator : sequentialEqualator;
-        }
-
-        //
-
-        @SuppressWarnings("unchecked")
-        public <I extends Iterable<U> & Sized> IntermediateOpTestBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
-            NodeBuilder<U> resultBuilder = shape.makeNodeBuilder(expectedResult.size());
-            resultBuilder.begin(expectedResult.size());
-            expectedResult.forEach(resultBuilder);
-            resultBuilder.end();
-            this.refResult = resultBuilder.build();
-            return this;
-        }
-
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> before(Block<TestData<T, S_IN>> before) {
-            this.before = Objects.requireNonNull(before);
-            return this;
-        }
-
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> after(Block<TestData<T, S_IN>> after) {
-            this.after = Objects.requireNonNull(after);
-            return this;
-        }
-
-        @SuppressWarnings("unchecked")
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> without(IntermediateOpTestScenario... tests) {
-            return without(Arrays.asList(tests));
-        }
-
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> without(Collection<? extends IntermediateOpTestScenario> tests) {
-            for (IntermediateOpTestScenario ts : tests) {
-                if (ts.getShape().getStreamType() == shape.getStreamType()) {
-                    testSet.remove(ts);
-                }
-            }
-
-            if (testSet.isEmpty()) {
-                throw new IllegalStateException("Test scenario set is empty");
-            }
-
-            return this;
-        }
-
-        @SuppressWarnings("unchecked")
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> with(IntermediateOpTestScenario... tests) {
-            return with(Arrays.asList(tests));
-        }
-
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> with(Collection<? extends IntermediateOpTestScenario> tests) {
-            testSet = new HashSet<>();
-
-            for (IntermediateOpTestScenario ts : tests) {
-                if (ts.getShape().getStreamType() == shape.getStreamType()) {
-                    testSet.add(ts);
-                }
-            }
-
-            if (testSet.isEmpty()) {
-                throw new IllegalStateException("Test scenario set is empty");
-            }
-
-            return this;
-        }
-
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> sequentialEqualator(BiPredicate<Iterable<U>, Iterable<U>> equalator) {
-            this.sequentialEqualator = equalator;
-            return this;
-        }
-
-        public IntermediateOpTestBuilder<T, U, S_IN, S_OUT> parallelEqualator(BiPredicate<Iterable<U>, Iterable<U>> equalator) {
-            this.parallelEqualator = equalator;
-            return this;
-        }
-
-        // Build method
-
-        public Node<U> exercise() {
-            return exerciseOps(this);
-        }
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    protected static <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> Node<U> exerciseOps(IntermediateOpTestBuilder<T, U, S_IN, S_OUT> b) {
-        Node<U> refResult;
-        if (b.refResult != null) {
-            refResult = b.refResult;
-        } else {
-            // Induce the reference result
-            b.before.apply(b.data);
-            S_OUT sOut = b.m.apply(b.data.stream());
-            refResult = ((AbstractPipeline<?, U>) sOut).collectOutput().flatten();
-            b.after.apply(b.data);
-        }
-
-        for (IntermediateOpTestScenario test : b.testSet) {
-            b.before.apply(b.data);
-
-            NodeBuilder<U> resultBuilder = b.shape.makeNodeBuilder(-1);
-            resultBuilder.begin(-1);
-            test.run(b.data, resultBuilder, b.m);
-            resultBuilder.end();
-            Node<U> result = resultBuilder.build();
-
-            assertTrue(b.getEqualator(test).test(result, refResult),
-                       String.format("%s %s: %s != %s", b.data.toString(), test, refResult, result));
-
-            b.after.apply(b.data);
-        }
-
-        return refResult;
-    }
-
-    // Exercise terminal operations
-
-    @SuppressWarnings("rawtypes")
-    protected <T, U, S_IN extends BaseStream<T>> U exerciseOps(TestData<T, S_IN> data, TerminalOp<T, U> terminal) {
-        return exerciseOps(data, terminal, new IntermediateOp[0]);
-    }
-
-    @SuppressWarnings("rawtypes")
-    protected <T, U, S_IN extends BaseStream<T>> U exerciseOps(TestData<T, S_IN> data, TerminalOp<T, U> terminal, IntermediateOp... ops) {
-        return exerciseOps(data, (u, v) -> Objects.equals(u,v), terminal, ops);
-    }
-
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected static <T, U, S_IN extends BaseStream<T>> U exerciseOps(TestData<T, S_IN> data,
-                                          BiPredicate<U, U> equalator,
-                                          TerminalOp<T, U> terminalOp,
-                                          IntermediateOp... ops) {
-
-        // Sequentially collect the output that will be input to the terminal op
-        Node<T> node = (Node<T>) data.seq(ops).collectOutput().flatten();
-        U refResult = chain(terminalOp.inputShape().stream(node),
-                            terminalOp);
-
-        // Single sequential using pull
-        {
-            // @@@ Using specific stream implementation
-            AbstractPipeline<?, T> source = terminalOp.inputShape().stream(node);
-            // Force pull by requesting iterator
-            // @@@ seems fragile is there a better way?
-            source.iterator();
-            U result = source.pipeline(terminalOp);
-            assertTrue(equalator.test(refResult, result), String.format("Single sequential pull: %s != %s", refResult, result));
-        }
-
-        // Single parallel
-        {
-            // @@@ Using specific stream implementation
-            AbstractPipeline<?, T> ap = terminalOp.inputShape().parallel(node);
-            U result = chain(ap, terminalOp);
-            assertTrue(equalator.test(refResult, result), String.format("Single parallel: %s != %s", refResult, result));
-        }
-
-        // All sequential
-        // This may push or pull depending on the terminal op implementation
-        {
-            U result = data.seq(terminalOp, ops);
-            assertTrue(equalator.test(refResult, result), String.format("All sequential: %s != %s", refResult, result));
-        }
-
-        // All sequential using pull
-        {
-            AbstractPipeline<?, T> ap = (AbstractPipeline<?, T>)data.seq(ops);
-            // Force pull by requesting iterator
-            // @@@ seems fragile is there a better way?
-            ap.iterator();
-            U result = ap.pipeline(terminalOp);
-            assertTrue(equalator.test(refResult, result), String.format("All sequential pull: %s != %s", refResult, result));
-        }
-
-        // All parallel
-        {
-            U resultPar = data.par(terminalOp, ops);
-            assertTrue(equalator.test(refResult, resultPar), String.format("All parallel: %s != %s", refResult, resultPar));
-        }
-
-        // All parallel using pull
-        {
-            AbstractPipeline<?, T> ap = (AbstractPipeline<?, T>)data.par(ops);
-            // Force pull by requesting iterator
-            // @@@ seems fragile is there a better way?
-            ap.iterator();
-            U result = ap.pipeline(terminalOp);
-            assertTrue(equalator.test(refResult, result), String.format("All parallel pull: %s != %s", refResult, result));
-        }
-
-        return refResult;
-    }
-
-    //
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static <T> AbstractPipeline<?, T> chain(AbstractPipeline upstream, IntermediateOp<?, T> op) {
-        return upstream.chain(op);
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static <U> U chain(AbstractPipeline pipe, TerminalOp<?, U> op) {
-        return (U) pipe.pipeline(op);
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static AbstractPipeline<?, ?> chain(AbstractPipeline pipe, IntermediateOp... ops) {
-        for (IntermediateOp op : ops)
-            pipe = chain(pipe, op);
-        return pipe;
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static <U> U chain(AbstractPipeline pipe, TerminalOp<?, U> terminal, IntermediateOp... ops) {
-        return chain(chain(pipe, ops), terminal);
-    }
-
-    // Test data
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static interface TestData<T, S extends BaseStream<T>> extends Iterable<T>, Streamable<S>, Sized {
-
-        // @@@ This is not used, should it be removed?
-        Spliterator<T> spliterator();
-
-        //
-
-        StreamShape getShape();
-
-        default <A extends Collection<? super T>> A into(A target) {
-            Iterator<T> iterator = iterator();
-            while (iterator.hasNext())
-                target.add(iterator.next());
-            return target;
-        }
-
-        // Streamable
-
-        @Override
-        S stream();
-
-        @Override
-        S parallel();
-
-        // Source
-
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        default AbstractPipeline<?, T> seq() {
-            return (AbstractPipeline<?, T>) stream();
-        }
-
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        default AbstractPipeline<?, T> par() {
-            return (AbstractPipeline<?, T>) stream();
-        }
-
-        // Intermediate
-
-        default <U> AbstractPipeline<?, U> seq(IntermediateOp<T, U> op) {
-            return chain(seq(), op);
-        }
-
-        default <U> AbstractPipeline<?, U> par(IntermediateOp<T, U> op) {
-            return chain(par(), op);
-        }
-
-        default AbstractPipeline<?, ?> seq(IntermediateOp... ops) {
-            return chain(seq(), ops);
-        }
-
-        default AbstractPipeline<?, ?> par(IntermediateOp... ops) {
-            return chain(par(), ops);
-        }
-
-        // Terminal
-
-        default <U> U seq(TerminalOp<T, U> op)  {
-            return chain(seq(), op);
-        }
-
-        default <U> U par(TerminalOp<T, U> op)  {
-            return chain(par(), op);
-        }
-
-        default <U> U seq(TerminalOp<?, U> terminal, IntermediateOp... ops) {
-            return chain(seq(), terminal, ops);
-        }
-
-        default <U> U par(TerminalOp<?, U> terminal, IntermediateOp... ops) {
-            return chain(par(), terminal, ops);
-        }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/StreamIntermediateOpTestScenario.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.function.Block;
-import java.util.function.Function;
-import java.util.stream.*;
-import java.util.stream.op.FlagDeclaringOp;
-import java.util.stream.op.IntermediateOp;
-
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum StreamIntermediateOpTestScenario implements OpTestCase.IntermediateOpTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            m.apply(data.stream()).forEach(b);
-        }
-    },
-
-    // Wrap as stream and into a list
-    STREAM_INTO(false) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            for (U t : m.apply(data.stream()).into(new ArrayList<U>())) {
-                b.apply(t);
-            }
-        }
-    },
-
-    // Wrap as stream and into a list
-    STREAM_TO_ARRAY(false) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            for (Object t : m.apply(data.stream()).toArray()) {
-                b.apply((U) t);
-            }
-        }
-    },
-
-    // Wrap as stream, and iterate in pull mode
-    STREAM_ITERATOR(false) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            for (Iterator<U> seqIter = m.apply(data.stream()).iterator(); seqIter.hasNext(); )
-                b.apply(seqIter.next());
-        }
-    },
-
-    // Wrap as stream, and iterate in mixed mode
-    STREAM_MIXED(false) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            Stream<U> stream = m.apply(data.stream());
-            Iterator<U> iter = stream.iterator();
-            if (iter.hasNext())
-                b.apply(iter.next());
-            stream.forEach(b);
-        }
-    },
-
-    // Wrap as two connected streams, request iterator for the upstream, and do forEach on the downstream
-    STREAM_MIXED_ITERATOR_FOR_EACH(false) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            AbstractPipeline<T, T> pipe1 = data.seq(new NoOp(data.getShape()));
-            Stream<U> pipe2 = m.apply((S_IN) pipe1);
-
-            pipe1.iterator();
-            pipe2.forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + sequential
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            m.apply(data.parallel()).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + toArray
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            for (Object t : m.apply(data.parallel()).toArray())
-                b.apply((U) t);
-        }
-    },
-
-    // Wrap as parallel stream + toArray and clear SIZED flag
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            AbstractPipeline<?, ?> pipe1 = data.par(new FlagDeclaringOp(StreamOpFlags.NOT_SIZED) {
-                @Override
-                public StreamShape outputShape() {
-                    return data.getShape();
-                }
-
-                @Override
-                public StreamShape inputShape() {
-                    return data.getShape();
-                }
-            });
-            Stream<U> pipe2 = m.apply((S_IN) pipe1);
-
-            for (Object t : pipe2.toArray())
-                b.apply((U) t);
-        }
-    },
-
-    // Wrap as parallel stream + into
-    PAR_STREAM_SEQUENTIAL_INTO(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            ArrayList<U> list = m.apply(data.parallel()).sequential().into(new ArrayList<U>());
-            for (U u : list)
-                b.apply(u);
-        }
-    },
-
-    // Wrap as parallel stream, and iterate in mixed mode
-    PAR_STREAM_ITERATOR_TO_ARRAY_MIXED(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            Stream<U> stream = m.apply(data.parallel());
-            Iterator<U> iter = stream.iterator();
-            if (iter.hasNext())
-                b.apply(iter.next());
-            for (Object t : stream.toArray())
-                b.apply((U) t);
-        }
-    },
-
-    // Wrap as two connected streams, request iterator for the upstream, and do forEach on the downstream
-    PAR_STREAM_MIXED_ITERATOR_TO_ARRAY(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            AbstractPipeline<T, T> pipe1 = data.seq(new NoOp(data.getShape()));
-            Stream<U> pipe2 = m.apply((S_IN) pipe1);
-
-            pipe1.iterator();
-            for (Object t : pipe2.toArray())
-                b.apply((U) t);
-        }
-    },
-
-    // Wrap as parallel stream, and iterate in mixed mode
-    PAR_STREAM_SEQUENTIAL_MIXED(true) {
-        <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m) {
-            Stream<U> stream = m.apply(data.parallel());
-            Iterator<U> iter = stream.iterator();
-            if (iter.hasNext())
-                b.apply(iter.next());
-            stream.sequential().forEach(b);
-        }
-    },
-
-    // More ways to iterate the PSS: iterate result of op
-    // Extends testing to test whether computation happens in- or out-of-thread
-    ;
-
-    private static class NoOp<T> implements IntermediateOp<T, T> {
-
-        private final StreamShape shape;
-
-        private NoOp(StreamShape shape) {
-            this.shape = shape;
-        }
-
-        @Override
-        public StreamShape inputShape() {
-            return shape;
-        }
-
-        @Override
-        public StreamShape outputShape() {
-            return shape;
-        }
-
-        @Override
-        public Iterator<T> wrapIterator(int flags, Iterator<T> in) {
-            return in;
-        }
-
-        @Override
-        public Sink<T> wrapSink(int flags, Sink<T> sink) {
-            return sink;
-        }
-    }
-
-    private boolean isParallel;
-
-    StreamIntermediateOpTestScenario(boolean isParallel) {
-        this.isParallel = isParallel;
-    }
-
-    public StreamShape getShape() {
-        return StreamShapeFactory.REFERENCE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public <T, U, S_IN extends BaseStream<T>, S_OUT extends BaseStream<U>> void run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<S_OUT, S_IN> m) {
-        _run(data, b, (Function<Stream<U>, S_IN>) m);
-    }
-
-    abstract <T, U, S_IN extends BaseStream<T>> void _run(OpTestCase.TestData<T, S_IN> data, Block<U> b, Function<Stream<U>, S_IN> m);
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/StreamOpFlagsTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream;
-
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.StreamOpFlags;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-@Test
-public class StreamOpFlagsTest {
-
-    public void test() {
-        int sourceFlags = StreamOpFlags.IS_SIZED | StreamOpFlags.IS_DISTINCT;
-
-        List<Integer> ops = Arrays.asList(StreamOpFlags.NOT_SIZED, StreamOpFlags.IS_ORDERED | StreamOpFlags.IS_SORTED);
-
-        int opsFlags = StreamOpFlags.INITIAL_OPS_VALUE;
-        for (int opFlags : ops) {
-            opsFlags = StreamOpFlags.combineOpFlags(opFlags, opsFlags);
-        }
-        int flags = StreamOpFlags.combineStreamFlags(sourceFlags, opsFlags);
-
-        assertFalse(StreamOpFlags.SIZED.isKnown(flags));
-        assertTrue(StreamOpFlags.DISTINCT.isKnown(flags));
-        assertTrue(StreamOpFlags.SORTED.isKnown(flags));
-        assertTrue(StreamOpFlags.ORDERED.isKnown(flags));
-
-        assertFalse(StreamOpFlags.SIZED.isKnownOnOpFlags(flags));
-        assertTrue(StreamOpFlags.DISTINCT.isKnownOnOpFlags(flags));
-        assertTrue(StreamOpFlags.SORTED.isKnownOnOpFlags(flags));
-        assertTrue(StreamOpFlags.ORDERED.isKnownOnOpFlags(flags));
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestData.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-package org.openjdk.tests.java.util.stream;/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.stream.*;
-
-public abstract class StreamTestData<T> implements OpTestCase.TestData<T, Stream<T>> {
-
-    @Override
-    @SuppressWarnings("rawtypes")
-    public StreamShape getShape() {
-        return StreamShapeFactory.REFERENCE;
-    }
-
-    public static class ArrayData<T> extends StreamTestData<T> {
-        private final String name;
-        private final T[] array;
-
-        public ArrayData(String name, T[] array) {
-            this.name = name;
-            this.array = array;
-        }
-
-        @Override
-        public Stream<T> stream() {
-            return Arrays.stream(array);
-        }
-
-        @Override
-        public Stream<T> parallel() {
-            return Arrays.parallel(array);
-        }
-
-        @Override
-        public Iterator<T> iterator() {
-            return Arrays.iterator(array);
-        }
-
-        @Override
-        public Spliterator<T> spliterator() {
-            return Arrays.spliterator(array);
-        }
-
-        @Override
-        public int size() {
-            return array.length;
-        }
-
-        @Override
-        public String toString() {
-            return name;
-        }
-    }
-
-    public static class CollectionData<T> extends StreamTestData<T> {
-        protected final String name;
-        protected final Collection<T> collection;
-
-        public CollectionData(String name, Collection<T> collection) {
-            this.name = name;
-            this.collection = collection;
-        }
-
-        @Override
-        public Stream<T> stream() {
-            return collection.stream();
-        }
-
-        @Override
-        public Stream<T> parallel() {
-            return collection.parallel();
-        }
-
-        @Override
-        public Iterator<T> iterator() {
-            return collection.iterator();
-        }
-
-        @Override
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        public Spliterator<T> spliterator() {
-            // @@@ FIXME!
-            return Arrays.spliterator((T[]) collection.toArray());
-        }
-
-        @Override
-        public int size() {
-            return collection.size();
-        }
-
-        @Override
-        public String toString() {
-            return getClass().getSimpleName() + "[" + name + "]";
-        }
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/StreamTestDataProvider.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream;
-
-import org.openjdk.tests.java.util.LambdaTestHelpers;
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.function.Combiner;
-
-/**
- * StreamTestDataProvider
- *
- * @author Brian Goetz
- */
-public class StreamTestDataProvider {
-    private static final Integer[] to0 = new Integer[0];
-    private static final Integer[] to1 = new Integer[1];
-    private static final Integer[] to10 = new Integer[10];
-    private static final Integer[] to100 = new Integer[100];
-    private static final Integer[] to1000 = new Integer[1000];
-    private static final Integer[] reversed = new Integer[100];
-    private static final Integer[] ones = new Integer[100];
-    private static final Integer[] twice = new Integer[200];
-    private static final Integer[] pseudoRandom;
-
-    private static final Object[][] testData;
-
-    static {
-        Integer[][] arrays = {to0, to1, to10, to100, to1000};
-        for (Integer[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        List<Object[]> list = new ArrayList<>();
-        for (Object[] data : arrays) {
-            final Object name = data[0];
-            final Integer[] ints = (Integer[])data[1];
-
-            list.add(e("array:" + name, ints, StreamTestData.ArrayData::new));
-            list.add(e("ArrayList.asList:" + name, Arrays.asList(ints), StreamTestData.CollectionData::new));
-            list.add(e("ArrayList:" + name, new ArrayList<>(Arrays.asList(ints)), StreamTestData.CollectionData::new));
-            list.add(e("HashSet:" + name, new HashSet<>(Arrays.asList(ints)), StreamTestData.CollectionData::new));
-            list.add(e("TreeSet:" + name, new TreeSet<>(Arrays.asList(ints)), StreamTestData.CollectionData::new));
-        }
-        testData = list.toArray(new Object[0][]);
-    }
-
-    static <T> Object[] e(String description, T[] data, Combiner<StreamTestData<T>, String, T[]> m) {
-        return new Object[] { description, m.combine(description, data) };
-    }
-
-    static <T> Object[] e(String description, Collection<T> data, Combiner<StreamTestData<T>, String, Collection<T>> m) {
-        return new Object[] { description, m.combine(description, data) };
-    }
-
-    // Return an array of ( String name, TestData<Integer> )
-    @DataProvider(name = "opArrays")
-    public static Object[][] makeValueTestData() {
-        return testData;
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ConcatOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.LambdaTestHelpers;
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-import sun.jvmstat.monitor.IntegerMonitor;
-
-import java.util.*;
-import java.util.stream.Streams;
-import java.util.stream.op.ConcatOp;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-@Test
-public class ConcatOpTest extends OpTestCase {
-
-    public void testRawIterator() {
-        assertCountSum(Iterators.concat(countTo(0).iterator(), countTo(0).iterator()), 0, 0);
-        assertCountSum(Iterators.concat(countTo(4).iterator(), countTo(0).iterator()), 4, 10);
-        assertCountSum(Iterators.concat(countTo(0).iterator(), countTo(4).iterator()), 4, 10);
-        assertCountSum(Iterators.concat(countTo(4).iterator(), countTo(4).iterator()), 8, 20);
-
-        List<Iterator<Integer>> lis = new ArrayList<>();
-        for (int i = 1; i < 8; i += 2) {
-            lis.add(range(i, i + 1).iterator());
-        }
-        assertCountSum(Iterators.concat(lis.iterator()), 8, 36);
-    }
-
-    public void testRawIteratorRemove() {
-        List<List<Integer>> ls = Streams.repeat(2, 2).
-                map(LambdaTestHelpers::countTo).into(new ArrayList<List<Integer>>());
-
-        List<Iterator<Integer>> lis = ls.stream().
-                map(i -> i.iterator()).into(new ArrayList<Iterator<Integer>>());
-
-        Iterator<Integer> i = Iterators.concat(lis.iterator());
-        while (i.hasNext()) {
-            i.next();
-            i.remove();
-        }
-
-        assertTrue(ls.stream().allMatch(l -> l.isEmpty()));
-    }
-
-    @Test(expectedExceptions = {IllegalStateException.class})
-    public void testRawIteratorRemoveTwice() {
-        Iterator<Integer> i = Iterators.concat(countTo(2).iterator(), countTo(2).iterator());
-        i.next();
-        i.remove();
-        i.remove();
-    }
-
-    @Test(expectedExceptions = {IllegalStateException.class})
-    public void testRawIteratorRemoveFirst() {
-        Iterator<Integer> i = Iterators.concat(countTo(2).iterator(), countTo(2).iterator());
-        i.remove();
-    }
-
-    public void testConcat() {
-        assertContents(Collections.<Integer>emptyList().stream().
-                concat(Collections.<Integer>emptyList().stream()).iterator(),
-                       Collections.<Integer>emptyList().iterator());
-
-        assertContents(countTo(10).stream().
-                concat(Collections.<Integer>emptyList().stream()).iterator(),
-                       countTo(10).stream().iterator());
-
-        assertContents(countTo(5).stream().
-                concat(range(6, 10).stream()).iterator(),
-                       countTo(10).stream().iterator());
-
-        assertContents(countTo(2).stream().
-                concat(range(3, 4).stream()).
-                concat(range(5, 6).stream()).
-                concat(range(7, 8).stream()).
-                concat(range(9, 10).stream()).iterator(),
-                       countTo(10).stream().iterator());
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOpsSequential(String name, StreamTestData<Integer> data) {
-        withData(data).
-                usingOpFactory(() -> new ConcatOp<>(data.stream())).
-                exercise();
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOpsParallel(String name, StreamTestData<Integer> data) {
-        withData(data).
-                usingOpFactory(() -> new ConcatOp<>(data.parallel())).
-                exercise();
-    }
-}
-
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/CumulateOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.stream.op.*;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * CumulateOpTest
- *
- * @author Brian Goetz
- */
-@Test
-public class CumulateOpTest extends OpTestCase {
-    public void testRawIterator() {
-        assertCountSum(CumulateOp.iterator(countTo(0).iterator(), rPlus), 0, 0);
-        assertContents(CumulateOp.iterator(countTo(5).iterator(), rPlus), 1, 3, 6, 10, 15);
-        assertContents(CumulateOp.iterator(countTo(5).iterator(), rMax), 1, 2, 3, 4, 5);
-        assertContents(CumulateOp.iterator(countTo(5).iterator(), rMin), 1, 1, 1, 1, 1);
-    }
-
-    public void testCumulate() {
-        assertCountSum(countTo(0).stream().cumulate(rPlus), 0, 0);
-        assertContents(countTo(5).stream().cumulate(rPlus).iterator(), 1, 3, 6, 10, 15);
-        assertContents(countTo(5).stream().map(mDoubler).cumulate(rPlus).iterator(), 2, 6, 12, 20, 30);
-        assertContents(countTo(5).stream().cumulate(rMax).iterator(), 1, 2, 3, 4, 5);
-        assertContents(countTo(5).stream().cumulate(rMin).iterator(), 1, 1, 1, 1, 1);
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        Node<Integer> result = exerciseOps(data, new CumulateOp<>(rPlus));
-        assertEquals(result.size(), data.size());
-
-        result = exerciseOps(data, new CumulateOp<>(rMin));
-        assertEquals(result.size(), data.size());
-
-        result = exerciseOps(data, new CumulateOp<>(rMax));
-        assertEquals(result.size(), data.size());
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testWithFilter(String name, StreamTestData<Integer> data) {
-        exerciseOps(data, new FilterOp<>(pEven), new CumulateOp<>(rPlus));
-        exerciseOps(data, new FilterOp<>(pEven), new MapOp<>(mDoubler), new CumulateOp<>(rPlus));
-        exerciseOps(data, new FilterOp<Integer>(x -> x == -1), new CumulateOp<>(rPlus));
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/FilterOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.Iterators;
-import java.util.stream.op.FilterOp;
-import java.util.stream.op.Node;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * FilterOpTest
- *
- * @author Brian Goetz
- */
-@Test
-public class FilterOpTest extends OpTestCase {
-    public void testRawIterator() {
-        assertCountSum(Iterators.filter(countTo(0).iterator(), pTrue), 0, 0);
-        assertCountSum(Iterators.filter(countTo(10).iterator(), pFalse), 0, 0);
-        assertCountSum(Iterators.filter(countTo(10).iterator(), pEven), 5, 30);
-        assertCountSum(Iterators.filter(countTo(10).iterator(), pOdd), 5, 25);
-        assertCountSum(Iterators.filter(countTo(10).iterator(), pTrue), 10, 55);
-        assertCountSum(Iterators.filter(Iterators.filter(countTo(10).iterator(), pEven), pOdd), 0, 0);
-    }
-
-    public void testFilter() {
-        assertCountSum(countTo(0).stream().filter(pTrue), 0, 0);
-        assertCountSum(countTo(10).stream().filter(pFalse), 0, 0);
-        assertCountSum(countTo(10).stream().filter(pEven), 5, 30);
-        assertCountSum(countTo(10).stream().filter(pOdd), 5, 25);
-        assertCountSum(countTo(10).stream().filter(pTrue), 10, 55);
-        assertCountSum(countTo(10).stream().filter(pEven).filter(pOdd), 0, 0);
-
-        exerciseOps(countTo(1000), s -> s.filter(pTrue), countTo(1000));
-        exerciseOps(countTo(1000), s -> s.filter(pFalse), countTo(0));
-        exerciseOps(countTo(1000), s -> s.filter(e -> e > 100), range(101, 1000));
-        exerciseOps(countTo(1000), s -> s.filter(e -> e < 100), countTo(99));
-        exerciseOps(countTo(1000), s -> s.filter(e -> e == 100), Arrays.asList(100));
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        Node<Integer> result = exerciseOps(data, new FilterOp<>(pTrue));
-        assertEquals(result.size(), data.size());
-
-        result = exerciseOps(data, new FilterOp<>(pFalse));
-        assertEquals(result.size(), 0);
-
-        exerciseOps(data, new FilterOp<>(pEven));
-        exerciseOps(data, new FilterOp<>(pOdd));
-
-        result = exerciseOps(data, new FilterOp<>(pOdd.and(pEven)));
-        assertEquals(result.size(), 0);
-
-        result = exerciseOps(data, new FilterOp<>(pOdd.or(pEven)));
-        assertEquals(result.size(), data.size());
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/FindAnyOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.Collections;
-import java.util.Optional;
-import java.util.function.BiPredicate;
-import java.util.stream.op.FilterOp;
-import java.util.stream.op.FindAnyOp;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-
-/**
- * FindAnyOpTest
- *
- */
-@Test
-public class FindAnyOpTest extends OpTestCase {
-    public void testRawIterator() {
-        FindAnyOp<Integer> op = FindAnyOp.singleton();
-        assertFalse(op.evaluate(Collections.<Integer>emptyIterator()).isPresent(), "no result");
-        assertTrue(op.evaluate(countTo(10).iterator()).isPresent(), "with result");
-    }
-
-    public void testFindAny() {
-        assertFalse(Collections.<Integer>emptySet().stream().findAny().isPresent(), "no result");
-        assertFalse(countTo(10).stream().filter(x -> x > 10).findAny().isPresent(), "no result");
-        assertTrue(countTo(10).stream().filter(pEven).findAny().isPresent(), "with result");
-    }
-
-    public void testFindAnyParallel() {
-        assertFalse(Collections.<Integer>emptySet().parallel().findAny().isPresent(), "no result");
-        assertFalse(countTo(1000).parallel().filter(x -> x > 1000).findAny().isPresent(), "no result");
-        assertTrue(countTo(1000).parallel().filter(pEven).findAny().isPresent(), "with result");
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        // @@@ Weak test -- only tests that all versions either find an answer or don't, don't assert validity of answer
-        // Would be good to test that the result is actually a member of the stream
-        BiPredicate<Optional<Integer>, Optional<Integer>> validAnswer = (a, b) -> a.isPresent() == b.isPresent();
-        exerciseOps(data, validAnswer, FindAnyOp.<Integer>singleton());
-        exerciseOps(data, validAnswer, FindAnyOp.<Integer>singleton(), new FilterOp<>(pTrue));
-        exerciseOps(data, validAnswer, FindAnyOp.<Integer>singleton(), new FilterOp<>(pEven));
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/FindFirstOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.stream.op.FilterOp;
-import java.util.stream.op.FindFirstOp;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-
-/**
- * FindFirstOpTest
- *
- */
-@Test
-public class FindFirstOpTest extends OpTestCase {
-    public void testRawIterator() {
-        FindFirstOp<Integer> op = FindFirstOp.singleton();
-        assertFalse(op.evaluate(Collections.<Integer>emptyIterator()).isPresent(), "no result");
-        assertEquals(1, (int) op.evaluate(countTo(10).iterator()).get(), "first element is 1");
-    }
-
-    public void testFindFirst() {
-        assertFalse(Collections.<Integer>emptySet().stream().findFirst().isPresent(), "no result");
-        assertFalse(countTo(10).stream().filter(x -> x > 10).findFirst().isPresent(), "no result");
-
-        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(pEven).findFirst().get() }).stream(), Arrays.asList(2));
-        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.findFirst().get() }).stream(), Arrays.asList(1));
-        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(e -> e == 499).findFirst().get() }).stream(), Arrays.asList(499));
-        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(e -> e == 999).findFirst().get() }).stream(), Arrays.asList(999));
-        exerciseOps(countTo(0), s-> Arrays.asList(new Integer[] { s.findFirst().orElse(-1) }).stream(), Arrays.asList(-1));
-        exerciseOps(countTo(1000), s-> Arrays.asList(new Integer[] { s.filter(e -> e == 1499).findFirst().orElse(-1) }).stream(), Arrays.asList(-1));
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        exerciseOps(data, FindFirstOp.<Integer>singleton());
-        exerciseOps(data, FindFirstOp.<Integer>singleton(), new FilterOp<>(pEven));
-        exerciseOps(data, FindFirstOp.<Integer>singleton(), new FilterOp<>(pTrue));
-        exerciseOps(data, FindFirstOp.<Integer>singleton(), new FilterOp<>(pFalse));
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testPipelines(String name, StreamTestData<Integer> data) {
-        Optional<Integer> seq, par;
-        seq = data.stream().findFirst();
-        par = data.parallel().findFirst();
-        assertEquals(par, seq);
-
-        seq = data.stream().filter(pEven).findFirst();
-        par = data.parallel().filter(pEven).findFirst();
-        assertEquals(par, seq);
-
-        seq = data.stream().filter(pTrue).findFirst();
-        par = data.parallel().filter(pTrue).findFirst();
-        assertEquals(par, seq);
-
-        seq = data.stream().filter(pFalse).findFirst();
-        par = data.parallel().filter(pFalse).findFirst();
-        assertEquals(par, seq);
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/FlagOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamIntermediateOpTestScenario;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.*;
-import java.util.function.Supplier;
-import java.util.stream.Sink;
-import java.util.stream.StreamOpFlags;
-import java.util.stream.op.*;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.countTo;
-
-@Test
-public class FlagOpTest extends OpTestCase {
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testFlagsPassThrough(String name, StreamTestData<Integer> data) {
-
-        @SuppressWarnings({"unchecked", "rawtypes"})
-        TestFlagPassThroughOp<Integer>[] ops = new TestFlagPassThroughOp[3];
-        ops[0] = new TestFlagPassThroughOp<>();
-        ops[1] = new TestFlagPassThroughOp<>();
-        ops[2] = new TestFlagPassThroughOp<>();
-
-        ops[0].set(null, ops[1]);
-        ops[1].set(ops[0], ops[2]);
-        ops[2].set(ops[1], null);
-
-        exerciseOps(data, ops);
-    }
-
-    static class TestFlagPassThroughOp<T> extends FlagDeclaringOp<T> {
-        TestFlagPassThroughOp<T> upstream;
-        TestFlagPassThroughOp<T> downstream;
-
-        TestFlagPassThroughOp() {
-            super(0);
-        }
-
-        void set(TestFlagPassThroughOp<T> upstream, TestFlagPassThroughOp<T> downstream)  {
-            this.upstream = upstream;
-            this.downstream = downstream;
-        }
-
-        int wrapFlags;
-
-        @Override
-        public Iterator<T> wrapIterator(int flags, Iterator<T> source) {
-            this.wrapFlags = flags;
-
-            if (upstream != null) {
-                assertTrue(flags == upstream.wrapFlags);
-            }
-
-            return source;
-        }
-
-        @Override
-        @SuppressWarnings({"unchecked", "rawtypes"})
-        public Sink<T> wrapSink(int flags, Sink sink) {
-            this.wrapFlags = flags;
-
-            if (downstream != null) {
-                assertTrue(flags == downstream.wrapFlags);
-            }
-
-            return sink;
-        }
-    }
-
-    public void testFlagsClearAllSet() {
-        int clearAllFlags = 0;
-        for (StreamOpFlags f : EnumSet.allOf(StreamOpFlags.class)) {
-            if (f.isStreamFlag()) {
-                clearAllFlags |= f.clear();
-            }
-        }
-
-        EnumSet<StreamOpFlags> known = EnumSet.noneOf(StreamOpFlags.class);
-        EnumSet<StreamOpFlags> notKnown = StreamOpFlags.allOfStreamFlags();
-
-        List<FlagDeclaringOp<Integer>> ops = new ArrayList<>();
-        ops.add(new FlagDeclaringOp<>(clearAllFlags));
-        for (StreamOpFlags f : StreamOpFlags.allOfStreamFlags()) {
-            ops.add(new TestFlagExpectedOp<>(f.set(),
-                                             known.clone(),
-                                             EnumSet.noneOf(StreamOpFlags.class),
-                                             notKnown.clone()));
-            known.add(f);
-            notKnown.remove(f);
-        }
-        ops.add(new TestFlagExpectedOp<>(0,
-                                         known.clone(),
-                                         EnumSet.noneOf(StreamOpFlags.class),
-                                         notKnown.clone()));
-
-        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
-        @SuppressWarnings("rawtypes")
-        FlagDeclaringOp[] opsArray = ops.toArray(new FlagDeclaringOp[ops.size()]);
-
-        withData(data).
-                using(opsArray).
-                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
-                exercise();
-    }
-
-    public void testFlagsSetAllClear() {
-        int setAllFlags = 0;
-        for (StreamOpFlags f : EnumSet.allOf(StreamOpFlags.class)) {
-            if (f.isStreamFlag()) {
-                setAllFlags |= f.set();
-            }
-        }
-
-        EnumSet<StreamOpFlags> known = StreamOpFlags.allOfStreamFlags();
-        EnumSet<StreamOpFlags> notKnown = EnumSet.noneOf(StreamOpFlags.class);
-
-        List<FlagDeclaringOp<Integer>> ops = new ArrayList<>();
-        ops.add(new FlagDeclaringOp<>(setAllFlags));
-        for (StreamOpFlags f : StreamOpFlags.allOfStreamFlags()) {
-            ops.add(new TestFlagExpectedOp<>(f.clear(),
-                                             known.clone(),
-                                             EnumSet.noneOf(StreamOpFlags.class),
-                                             notKnown.clone()));
-            known.remove(f);
-            notKnown.add(f);
-        }
-        ops.add(new TestFlagExpectedOp<>(0,
-                                         known.clone(),
-                                         EnumSet.noneOf(StreamOpFlags.class),
-                                         notKnown.clone()));
-
-        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
-        @SuppressWarnings("rawtypes")
-        FlagDeclaringOp[] opsArray = ops.toArray(new FlagDeclaringOp[ops.size()]);
-
-
-        withData(data).
-                using(opsArray).
-                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
-                exercise();
-    }
-
-    public void testFlagsSetParallelCollect() {
-        testFlagsSetSequence(CollectorOps::parallelCollector);
-    }
-
-    public void testFlagsSetSequentialCollect() {
-        testFlagsSetSequence(CollectorOps::sequentialCollector);
-    }
-
-    private void testFlagsSetSequence(Supplier<StatefulOp<Integer, Integer>> cf) {
-        EnumSet<StreamOpFlags> known = EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED);
-        EnumSet<StreamOpFlags> preserve = EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED);
-
-        List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
-        for (StreamOpFlags f : EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED)) {
-            ops.add(cf.get());
-            ops.add(new TestFlagExpectedOp<>(f.set(),
-                                             known.clone(),
-                                             preserve.clone(),
-                                             EnumSet.noneOf(StreamOpFlags.class)));
-            known.add(f);
-            preserve.remove(f);
-        }
-        ops.add(cf.get());
-        ops.add(new TestFlagExpectedOp<>(0,
-                                         known.clone(),
-                                         preserve.clone(),
-                                         EnumSet.noneOf(StreamOpFlags.class)));
-
-        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
-        @SuppressWarnings("rawtypes")
-        IntermediateOp[] opsArray = ops.toArray(new IntermediateOp[ops.size()]);
-
-        withData(data).
-                using(opsArray).
-                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
-                exercise();
-    }
-
-
-    public void testFlagsClearParallelCollect() {
-        testFlagsClearSequence(CollectorOps::parallelCollector);
-    }
-
-    public void testFlagsClearSequentialCollect() {
-        testFlagsClearSequence(CollectorOps::sequentialCollector);
-    }
-
-    protected void testFlagsClearSequence(Supplier<StatefulOp<Integer, Integer>> cf) {
-        EnumSet<StreamOpFlags> preserve = EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED);
-        EnumSet<StreamOpFlags> notKnown = EnumSet.noneOf(StreamOpFlags.class);
-
-        List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
-        for (StreamOpFlags f : EnumSet.of(StreamOpFlags.DISTINCT, StreamOpFlags.SORTED)) {
-            ops.add(cf.get());
-            ops.add(new TestFlagExpectedOp<>(f.clear(),
-                                             EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED),
-                                             preserve.clone(),
-                                             notKnown));
-            notKnown.add(f);
-            preserve.remove(f);
-        }
-        ops.add(cf.get());
-        ops.add(new TestFlagExpectedOp<>(0,
-                                         EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED),
-                                         preserve.clone(),
-                                         EnumSet.noneOf(StreamOpFlags.class)));
-
-        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
-        @SuppressWarnings("rawtypes")
-        IntermediateOp[] opsArray = ops.toArray(new IntermediateOp[ops.size()]);
-
-        withData(data).
-                using(opsArray).
-                without(StreamIntermediateOpTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
-                exercise();
-    }
-
-    public void testFlagsSizedOrderedParallelCollect() {
-        EnumSet<StreamOpFlags> parKnown = EnumSet.of(StreamOpFlags.ORDERED, StreamOpFlags.SIZED);
-        EnumSet<StreamOpFlags> serKnown = parKnown.clone();
-
-        List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
-        for (StreamOpFlags f : parKnown) {
-            ops.add(CollectorOps.<Integer>parallelCollector());
-            ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
-                                             parKnown,
-                                             serKnown));
-            serKnown.remove(f);
-        }
-        ops.add(CollectorOps.<Integer>parallelCollector());
-        ops.add(new ParSerTestFlagExpectedOp<>(0,
-                                         parKnown,
-                                         EnumSet.noneOf(StreamOpFlags.class)));
-
-        StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
-        @SuppressWarnings("rawtypes")
-        IntermediateOp[] opsArray = ops.toArray(new IntermediateOp[ops.size()]);
-
-        exerciseOps(data, opsArray);
-    }
-
-    static class ParSerTestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
-        final EnumSet<StreamOpFlags> parKnown;
-        final EnumSet<StreamOpFlags> serKnown;
-
-        ParSerTestFlagExpectedOp(int flags, EnumSet<StreamOpFlags> known, EnumSet<StreamOpFlags> serKnown) {
-            super(flags);
-            this.parKnown = known;
-            this.serKnown = serKnown;
-        }
-
-        @Override
-        public Iterator<T> wrapIterator(int flags, Iterator<T> downstream) {
-            assertFlags(flags);
-            return downstream;
-        }
-
-        @Override
-        @SuppressWarnings({"unchecked", "rawtypes"})
-        public Sink<T> wrapSink(int flags, Sink upstream) {
-            assertFlags(flags);
-            return upstream;
-        }
-
-        protected void assertFlags(int flags) {
-            if (StreamOpFlags.PARALLEL.isKnown(flags)) {
-                for (StreamOpFlags f : parKnown) {
-                    Assert.assertTrue(f.isKnown(flags), String.format("Flag %s is not known, but should be known.", f.toString()));
-                }
-
-            } else {
-                for (StreamOpFlags f : serKnown) {
-                    Assert.assertTrue(f.isKnown(flags), String.format("Flag %s is not known, but should be known.", f.toString()));
-                }
-
-            }
-        }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/FlatMapOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.function.Block;
-import java.util.function.FlatMapper;
-import java.util.stream.Stream;
-import java.util.stream.op.FlatMapOp;
-import java.util.stream.op.Node;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * FlatMapOpTest
- *
- * @author Brian Goetz
- */
-@Test
-public class FlatMapOpTest extends OpTestCase {
-    private static final FlatMapper<Integer, Integer> mfIntToBits = (block, integer) -> {
-        int num = integer;
-        for (int i = 0; i < 16 && num != 0; i++) {
-            if ((num & (1 << i)) != 0) {
-                num &= ~(1 << i);
-                block.apply(i);
-            }
-        }
-    };
-
-    public void testRawIterator() {
-        assertCountSum(FlatMapOp.iterator(countTo(10).iterator(), mfId), 10, 55);
-        assertCountSum(FlatMapOp.iterator(countTo(10).iterator(), mfNull), 0, 0);
-        assertCountSum(FlatMapOp.iterator(countTo(3).iterator(), mfLt), 6, 4);
-    }
-
-    public void testFlatMap() {
-        String[] stringsArray = {"hello", "there", "", "yada"};
-        Stream<String> strings = Arrays.asList(stringsArray).stream();
-        assertConcat(strings.flatMap(flattenChars).iterator(), "hellothereyada");
-
-        assertCountSum(countTo(10).stream().flatMap(mfId), 10, 55);
-        assertCountSum(countTo(10).stream().flatMap(mfNull), 0, 0);
-        assertCountSum(countTo(3).stream().flatMap(mfLt), 6, 4);
-
-        exerciseOps(new StreamTestData.ArrayData<>("stringsArray", stringsArray), new FlatMapOp<>(flattenChars));
-        exerciseOps(new StreamTestData.ArrayData<>("LONG_STRING", new String[]{LONG_STRING}), new FlatMapOp<>(flattenChars));
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        Node<Integer> result = exerciseOps(data, new FlatMapOp<>(mfId));
-        assertEquals(data.size(), result.size());
-
-        result = exerciseOps(data, new FlatMapOp<>(mfNull));
-        assertEquals(0, result.size());
-
-        result = exerciseOps(data, new FlatMapOp<>(mfId));
-        assertEquals(result.size(), data.size());
-
-        exerciseOps(data, new FlatMapOp<>(mfLt));
-        exerciseOps(data, new FlatMapOp<>(mfIntToBits));
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ForEachOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.op.ForEachOp;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * ForEachOpTest
- */
-@Test
-public class ForEachOpTest extends OpTestCase {
-
-    public void testForEachParallel() {
-        AtomicInteger count = new AtomicInteger(0);
-        AtomicInteger sum = new AtomicInteger(0);
-        countTo(10).parallel().forEach(e -> { count.incrementAndGet(); sum.addAndGet(e); });
-        assertEquals(count.get(), 10);
-        assertEquals(sum.get(), 55);
-    }
-
-    public void testForEachStream() {
-        List<Integer> counted = countTo(10);
-        List<Integer> eached = new ArrayList<>();
-        counted.stream().forEach(e -> { eached.add(e); });
-        assertContents(eached.iterator(), counted.iterator());
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    @SuppressWarnings("unchecked")
-    public void testOps(String name, StreamTestData<Integer> data) {
-       Object result = exerciseOps(data, ForEachOp.<Integer>make(bEmpty));
-       assertEquals(result, null);
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/GroupByOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.*;
-import java.util.function.*;
-import java.util.stream.Stream;
-import java.util.stream.StreamOpFlags;
-import java.util.stream.op.GroupByOp;
-import java.util.stream.op.FlagDeclaringOp;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * GroupByOpTest
- *
- */
-@Test
-public class GroupByOpTest extends OpTestCase {
-
-    public void testRawIterator() {
-        GroupByOp<Integer, Boolean> grouping = new GroupByOp<>(Functions.forPredicate(pEven, true, false));
-
-        Map<Boolean,Collection<Integer>> result = iteratorToStatefulSink(countTo(10).iterator(), grouping.sink());
-
-        assertEquals(2, result.keySet().size());
-        for(Collection<Integer> group : result.values()) {
-            int count = 0;
-            Stream<Integer> stream = group.stream();
-            Iterator<Integer> it = stream.iterator();
-            while (it.hasNext()) {
-                it.next();
-                ++count;
-            }
-            assertEquals(5, count);
-        }
-    }
-
-    public void testGroupBy() {
-        Map<Boolean,Collection<Integer>> result = countTo(10).stream().groupBy(Functions.forPredicate(pEven, true, false));
-
-        assertEquals(2, result.keySet().size());
-        for(Collection<Integer> group : result.values()) {
-            int count = 0;
-            Stream<Integer> stream = group.stream();
-            Iterator<Integer> it = stream.iterator();
-            while (it.hasNext()) {
-                it.next();
-                ++count;
-            }
-            assertEquals(5, count);
-        }
-    }
-
-    static class MapperData<T, K> {
-        Function<K, T> m;
-        int expectedSize;
-
-        MapperData(Function<K, T> m, int expectedSize) {
-            this.m = m;
-            this.expectedSize = expectedSize;
-        }
-    }
-
-    List<MapperData<Integer, ?>> getMapperData(StreamTestData<Integer> data) {
-        int uniqueSize = data.into(new HashSet<>()).size();
-
-        return Arrays.<MapperData<Integer, ?>>asList(
-            new MapperData<>(mId, uniqueSize),
-            new MapperData<>(mZero, Math.min(1, data.size())),
-            new MapperData<>(mDoubler, uniqueSize),
-            new MapperData<>(mId.compose(mDoubler), uniqueSize),
-            new MapperData<>(mDoubler.compose(mDoubler), uniqueSize),
-
-            new MapperData<>(Functions.forPredicate(pFalse, true, false), Math.min(1, uniqueSize)),
-            new MapperData<>(Functions.forPredicate(pTrue, true, false), Math.min(1, uniqueSize)),
-            new MapperData<>(Functions.forPredicate(pEven, true, false), Math.min(2, uniqueSize)),
-            new MapperData<>(Functions.forPredicate(pOdd, true, false), Math.min(2, uniqueSize))
-        );
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        // @@@ More things to test here:
-        //     - Every value in data is present in right bucket
-        //     - Total number of values equals size of data
-
-        for (MapperData<Integer, ?> md : getMapperData(data)) {
-            Map<?, Collection<Integer>> result = exerciseOps(data,
-                                                             new GroupByOp<Integer, Object>(md.m));
-            assertEquals(result.keySet().size(), md.expectedSize);
-        }
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testWithUnorderedOp(String name, StreamTestData<Integer> data) {
-        // @@@ More things to test here:
-        //     - Every value in data is present in right bucket
-        //     - Total number of values equals size of data
-
-        for (MapperData<Integer, ?> md : getMapperData(data)) {
-            Map<?, Collection<Integer>> result = exerciseOps(data,
-                                                             this::multiMapEquals,
-                                                             new GroupByOp<Integer, Object>(md.m),
-                                                             new FlagDeclaringOp<>(StreamOpFlags.NOT_ORDERED));
-            assertEquals(result.keySet().size(), md.expectedSize);
-        }
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testWithValueFactory(String name, StreamTestData<Integer> data) {
-        Map<Integer, Collection<Integer>> miResult = exerciseOps(data, new GroupByOp<Integer, Integer>(mId, LinkedList::new));
-
-        Set<Class<?>> classes = miResult.values().stream().map(e -> e.getClass()).into(new HashSet<Class<?>>());
-
-        if (data.size() > 0) {
-            assertEquals(classes.size(), 1);
-            assertEquals(LinkedList.class, classes.iterator().next());
-        }
-    }
-
-    <K, V> boolean multiMapEquals(Map<K, Collection<V>> a, Map<K, Collection<V>> b) {
-        if (!Objects.equals(a.keySet(), b.keySet())) {
-            return false;
-        }
-
-        for (K k : a.keySet()) {
-            Set<V> as = new HashSet<>(a.get(k));
-            Set<V> bs = new HashSet<>(b.get(k));
-            if (!Objects.equals(as, bs)) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/InfiniteStreamWithLimitOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.stream.Stream;
-import java.util.stream.Streams;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.assertContents;
-
-
-@Test
-public class InfiniteStreamWithLimitOpTest extends OpTestCase {
-
-    public void testRepeatLimit() {
-        assertContents(
-                Streams.repeat("A").limit(10).iterator(),
-                Streams.repeat(10, "A").iterator());
-    }
-
-    public void testRepeatedlyLimit() {
-        assertContents(
-                Streams.repeatedly(() -> "A").limit(10).iterator(),
-                Streams.repeatedly(10, () -> "A").iterator());
-    }
-
-    public void testIterateLimit() {
-        assertContents(
-                Streams.iterate("A", s -> s).limit(10).iterator(),
-                Streams.repeat(10, "A").iterator());
-    }
-
-    public void testIterateFibLimit() {
-        Stream<Integer> fib = Streams.
-                iterate(new int[]{0, 1}, pair -> new int[]{pair[1], pair[0] + pair[1]}).
-                map(pair -> (Integer) pair[0]);
-
-        assertContents(
-                fib.limit(10).iterator(),
-                Arrays.asList(0, 1, 1, 2, 3, 5, 8, 13, 21, 34).iterator());
-    }
-
-    public void testEmptyCycle() {
-        assertContents(
-                Streams.cycle(Collections.emptyList()).iterator(),
-                Collections.emptyList().iterator());
-    }
-
-    public void testCycleLimit() {
-        assertContents(
-                Streams.cycle(Arrays.asList(0, 1, 2, 3)).limit(16).iterator(),
-                Streams.iterate(0, i -> (i + 1) % 4).limit(16).iterator());
-    }
-
-    public void testCycleSkipLimit() {
-        assertContents(
-                Streams.cycle(Arrays.asList(0, 1, 2, 3)).skip(2).limit(16).iterator(),
-                Streams.iterate(2, i -> (i + 1) % 4).limit(16).iterator());
-    }
-
-    public void testInfiniteToMatchOp() {
-        assertFalse(Streams.cycle(Arrays.asList(1, 2, 3, 4)).allMatch(i -> i > 3));
-        assertTrue(Streams.cycle(Arrays.asList(1, 2, 3, 4)).anyMatch(i -> i > 3));
-        assertFalse(Streams.cycle(Arrays.asList(1, 2, 3, 4)).noneMatch(i -> i > 3));
-    }
-
-    public void testInfiniteWithLimitToShortCircuitTerminal() {
-        Streams.repeat(1).limit(4).toArray();
-        Streams.repeat(1).limit(4).filter(i -> true).toArray();
-        Streams.repeat(1).limit(4).into(new ArrayList<>());
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/IntNodeTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.op.Node;
-import java.util.stream.primitive.*;
-
-import static org.testng.Assert.*;
-
-@Test
-public class IntNodeTest {
-
-    @DataProvider(name = "nodes")
-    public Object[][] createSizes() {
-        List<Object[]> params = new ArrayList<>();
-
-        for (int size : Arrays.asList(0, 1, 4, 15, 16, 17, 127, 128, 129, 1000)) {
-            int[] array = new int[size];
-            for (int i = 0; i < array.length; i++) {
-                array[i] = i;
-            }
-
-            List<Node<Integer>> nodes = new ArrayList<>();
-
-            nodes.add(IntNodes.node(array));
-
-            nodes.add(degenerateTree(Primitives.iterator(array)));
-
-            nodes.add(tree(toList(array), l -> IntNodes.node(toIntArray(l))));
-
-            nodes.add(fill(array, IntNodes.makeBuilder(array.length)));
-
-            nodes.add(fill(array, IntNodes.makeVariableSizeBuilder()));
-
-            for (int i = 0; i < nodes.size(); i++) {
-                params.add(new Object[]{array, nodes.get(i)});
-            }
-
-        }
-
-        return params.toArray(new Object[0][]);
-    }
-
-    List<Integer> toList(int[] a) {
-        List<Integer> l = new ArrayList<>();
-        for (int i : a) {
-            l.add(i);
-        }
-
-        return l;
-    }
-
-    int[] toIntArray(List<Integer> l) {
-        int[] a = new int[l.size()];
-
-        int i = 0;
-        for (Integer e : l) {
-            a[i++] = e;
-        }
-        return a;
-    }
-
-    IntNode fill(int[] array, IntNodeBuilder nb) {
-        nb.begin(array.length);
-        for (Integer i : array) {
-            nb.applyInt(i);
-        }
-        nb.end();
-        return nb.build();
-    }
-
-    IntNode degenerateTree(IntIterator it) {
-        if (!it.hasNext()) {
-            return IntNodes.node(new int[0]);
-        }
-
-        int i = it.nextInt();
-        if (it.hasNext()) {
-            return IntNodes.node(IntNodes.node(new int[]{i}), degenerateTree(it));
-        }
-        else {
-            return IntNodes.node(new int[]{i});
-        }
-    }
-
-    IntNode tree(List<Integer> l, Function<IntNode, List<Integer>> m) {
-        if (l.size() < 3) {
-            return m.apply(l);
-        }
-        else {
-            return IntNodes.node(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
-        }
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testAsArray(int[] array, IntNode n) {
-        assertEquals(n.asIntArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testFlattenAsArray(int[] array, IntNode n) {
-        assertEquals(n.flatten().asIntArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testCopyTo(int[] array, IntNode n) {
-        int[] copy = new int[n.size()];
-        n.copyInto(copy, 0);
-
-        assertEquals(copy, array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testForEach(int[] array, IntNode n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        n.forEach(e -> {
-            l.add(e);
-        });
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testIterator(int[] array, IntNode n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        IntIterator it = n.iterator();
-        while (it.hasNext()) {
-            l.add(it.nextInt());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testRootSpliterator(int[] array, IntNode n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        IntIterator it = n.spliterator().iterator();
-        while (it.hasNext()) {
-            l.add(it.nextInt());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testDepthOneSpliterator(int[] array, IntNode n) {
-        List<Integer> l = new ArrayList<>(n.size());
-
-        IntSpliterator s = n.spliterator();
-        for (int i = 0; i < s.getNaturalSplits(); i++) {
-            IntIterator it = s.split().iterator();
-            while (it.hasNext()) {
-                l.add(it.nextInt());
-            }
-        }
-
-        IntIterator it = s.iterator();
-        while (it.hasNext()) {
-            l.add(it.nextInt());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testTwoSpliterator(int[] array, IntNode n) {
-        List<Integer> l = new ArrayList<>(n.size());
-
-        IntSpliterator s2 = n.spliterator();
-        IntSpliterator s1 = s2.split();
-
-        IntIterator it = s1.iterator();
-        while (it.hasNext()) {
-            l.add(it.nextInt());
-        }
-
-        it = s2.iterator();
-        while (it.hasNext()) {
-            l.add(it.nextInt());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testSpliterator(int[] array, IntNode n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        split(l, n.spliterator());
-
-        assertEquals(l.toArray(), array);
-    }
-
-    void split(List<Integer> l, IntSpliterator s) {
-        if (s.getNaturalSplits() == 0) {
-            IntSpliterator _s = s.split();
-            assertEquals(_s.getNaturalSplits(), 0);
-            assertFalse(_s.split().iterator().hasNext());
-
-            s.forEach(e -> {
-                l.add(e);
-            });
-        }
-        else {
-            int size = s.getSizeIfKnown();
-            for (int i = 0; i < s.getNaturalSplits(); i++) {
-                IntSpliterator _s = s.split();
-                split(l, _s);
-            }
-
-            assertTrue(s.getSizeIfKnown() < size);
-
-            split(l, s);
-        }
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/MapOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.Iterators;
-import java.util.function.Block;
-import java.util.stream.op.MapOp;
-import java.util.stream.op.Node;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * MapOpTest
- *
- * @author Brian Goetz
- */
-@Test
-public class MapOpTest extends OpTestCase {
-    public void testRawIterator() {
-        assertCountSum(Iterators.map(countTo(0).iterator(), mId), 0, 0);
-        assertCountSum(Iterators.map(countTo(10).iterator(), mId), 10, 55);
-        assertCountSum(Iterators.map(countTo(10).iterator(), mZero), 10, 0);
-        assertCountSum(Iterators.map(countTo(0).iterator(), mDoubler), 0, 0);
-        assertCountSum(Iterators.map(countTo(10).iterator(), mDoubler), 10, 110);
-        assertCountSum(Iterators.map(Iterators.map(countTo(10).iterator(), mDoubler), mDoubler), 10, 220);
-    }
-
-    public void testMap() {
-        assertCountSum(countTo(0).stream().map(mId), 0, 0);
-        assertCountSum(countTo(10).stream().map(mId), 10, 55);
-        assertCountSum(countTo(10).stream().map(mZero), 10, 0);
-        assertCountSum(countTo(0).stream().map(mDoubler), 0, 0);
-        assertCountSum(countTo(10).stream().map(mDoubler), 10, 110);
-        assertCountSum(countTo(10).stream().map(mDoubler).map(mDoubler), 10, 220);
-
-
-        exerciseOps(countTo(0), s -> s.map(e -> e), countTo(0));
-        exerciseOps(countTo(1000), s -> s.map(e -> e), countTo(1000));
-        exerciseOps(countTo(1000), s -> s.map(e -> (1000+e)), range(1001, 2000));
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        Node<Integer> result = exerciseOps(data, new MapOp<>(mId));
-        assertEquals(data.size(), result.size());
-
-        result = exerciseOps(data, new MapOp<>(mZero));
-        assertEquals(data.size(), result.size());
-
-        result = exerciseOps(data, new MapOp<>(mDoubler));
-        assertEquals(data.size(), result.size());
-
-        result = exerciseOps(data, new MapOp<>(mId.compose(mDoubler)));
-        assertEquals(data.size(), result.size());
-
-        result = exerciseOps(data, new MapOp<>(mDoubler.compose(mDoubler)));
-        assertEquals(data.size(), result.size());
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/MatchOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-import java.util.stream.Streamable;
-import java.util.stream.op.FilterOp;
-import java.util.stream.op.MatchOp;
-
-import static java.util.stream.op.MatchOp.MatchKind;
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * MatchOpTest
- *
- * @author Brian Goetz
- */
-@Test
-public class MatchOpTest extends OpTestCase {
-    @SuppressWarnings({ "unchecked", "raw" })
-    private static final Predicate<Integer>[] INTEGER_PREDICATES
-            = (Predicate<Integer>[]) new Predicate<?>[] { pTrue, pFalse, pEven, pOdd };
-
-    private<T> void assertPredicates(Streamable<Stream<T>> source, MatchKind matchKind, Predicate<T>[] predicates, boolean... answers) {
-        for (int i=0; i<predicates.length; i++) {
-            boolean match;
-            switch (matchKind) {
-                case ANY: match = source.stream().anyMatch(predicates[i]); break;
-                case ALL: match = source.stream().allMatch(predicates[i]); break;
-                case NONE: match = source.stream().noneMatch(predicates[i]); break;
-                default: throw new IllegalStateException();
-            }
-            assertEquals(answers[i], match, matchKind.toString() + predicates[i].toString());
-        }
-    }
-
-    public void testMatches() {
-        assertPredicates(countTo(0), MatchKind.ANY, INTEGER_PREDICATES, false, false, false, false);
-        assertPredicates(countTo(0), MatchKind.ALL, INTEGER_PREDICATES, true, true, true, true);
-        assertPredicates(countTo(0), MatchKind.NONE, INTEGER_PREDICATES, true, true, true, true);
-
-        assertPredicates(countTo(1), MatchKind.ANY, INTEGER_PREDICATES, true, false, false, true);
-        assertPredicates(countTo(1), MatchKind.ALL, INTEGER_PREDICATES, true, false, false, true);
-        assertPredicates(countTo(1), MatchKind.NONE, INTEGER_PREDICATES, false, true, true, false);
-
-        assertPredicates(countTo(5), MatchKind.ANY, INTEGER_PREDICATES, true, false, true, true);
-        assertPredicates(countTo(5), MatchKind.ALL, INTEGER_PREDICATES, true, false, false, false);
-        assertPredicates(countTo(5), MatchKind.NONE, INTEGER_PREDICATES, false, true, false, false);
-    }
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        for (Predicate<Integer> p : INTEGER_PREDICATES)
-            for (MatchKind matchKind : MatchKind.values()) {
-                exerciseOps(data, MatchOp.make(p, matchKind));
-                exerciseOps(data, MatchOp.make(p, matchKind), new FilterOp<>(pFalse));
-                exerciseOps(data, MatchOp.make(p, matchKind), new FilterOp<>(pEven));
-            }
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeBuilderTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.function.Function;
-import java.util.stream.op.NodeBuilder;
-import java.util.stream.op.Nodes;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.assertContents;
-import static org.openjdk.tests.java.util.LambdaTestHelpers.countTo;
-import static org.testng.Assert.assertEquals;
-
-@Test
-public class NodeBuilderTest {
-
-    @DataProvider(name = "sizes")
-    public Object[][] createSizes() {
-        List<Integer> sizes = Arrays.asList(0, 1, 4, 16, 256,
-                                            1023, 1024, 1025,
-                                            2047, 2048, 2049,
-                                            1024 * 32 - 1, 1024 * 32, 1024 * 32 + 1);
-
-        List<List<Integer>> ls = new ArrayList<>();
-        for (Integer size : sizes) {
-            ls.add(countTo(size));
-        }
-
-        List<Function<NodeBuilder<Integer>, Integer>> ms = Arrays.<Function<NodeBuilder<Integer>, Integer>>asList(
-                s -> Nodes.makeVariableSizeBuilder(),
-                s -> Nodes.makeBuilder(s)
-        );
-
-        Object[][] params = new Object[ls.size() * ms.size()][];
-        int i = 0;
-        for (List<Integer> l : ls) {
-            for (Function<NodeBuilder<Integer>, Integer> m : ms) {
-                params[i++] = new Object[]{l, m};
-            }
-        }
-
-        return params;
-    }
-
-    @Test(dataProvider = "sizes")
-    public void testIteration(List<Integer> l, Function<NodeBuilder<Integer>, Integer> m) {
-        NodeBuilder<Integer> nb = m.apply(l.size());
-        nb.begin(l.size());
-        for (int i : l) {
-            nb.apply(i);
-        }
-        nb.end();
-
-        assertEquals(nb.size(), l.size());
-
-        {
-            List<Integer> _l = new ArrayList<>();
-            nb.forEach(e -> {
-                _l.add(e);
-            });
-
-            assertContents(_l, l);
-        }
-
-        {
-            List<Integer> _l = new ArrayList<>();
-            for (int i : nb) {
-                _l.add(i);
-            }
-
-            assertContents(_l, l);
-        }
-    }
-
-    @Test(dataProvider = "sizes")
-    public void testUpdate(List<Integer> l, Function<NodeBuilder<Integer>, Integer> m) {
-        NodeBuilder<Integer> nb = m.apply(l.size());
-        nb.begin(l.size());
-        for (int i : l) {
-            nb.apply(i);
-        }
-        nb.end();
-
-        // Negate each element
-        nb.forEachUpdate(e -> -e);
-
-        // Sum of original list and builder must be 0
-        int sum = 0;
-        Iterator<Integer> lit = l.iterator();
-        for (int i : nb) {
-            sum += i + lit.next();
-        }
-
-        assertEquals(sum, 0);
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/NodeTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.util.*;
-import java.util.function.Function;
-import java.util.stream.Spliterator;
-import java.util.stream.Stream;
-import java.util.stream.Streamable;
-import java.util.stream.op.Node;
-import java.util.stream.op.NodeBuilder;
-import java.util.stream.op.Nodes;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-@Test
-public class NodeTest {
-
-    @DataProvider(name = "nodes")
-    public Object[][] createSizes() {
-        List<Object[]> params = new ArrayList<>();
-
-        for (int size : Arrays.asList(0, 1, 4, 15, 16, 17, 127, 128, 129, 1000)) {
-            Integer[] array = new Integer[size];
-            for (int i = 0; i < array.length; i++) {
-                array[i] = i;
-            }
-
-            List<Node<Integer>> nodes = new ArrayList<>();
-            nodes.add(Nodes.node(array));
-            nodes.add(Nodes.node(Arrays.asList(array)));
-            nodes.add(Nodes.node((Streamable<Stream<Integer>>) Arrays.asList(array)));
-            nodes.add(Nodes.node(Arrays.asList(array).stream()));
-            nodes.add(Nodes.node(Arrays.asList(array).parallel()));
-            nodes.add(degenerateTree(Arrays.asList(array).iterator()));
-            nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l.toArray(new Integer[l.size()]))));
-            nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l)));
-            nodes.add(fill(array, Nodes.<Integer>makeBuilder(array.length)));
-            nodes.add(fill(array, Nodes.<Integer>makeVariableSizeBuilder()));
-
-            for (int i = 0; i < nodes.size(); i++) {
-                params.add(new Object[]{array, nodes.get(i)});
-            }
-
-        }
-
-        return params.toArray(new Object[0][]);
-    }
-
-    Node<Integer> fill(Integer[] array, NodeBuilder<Integer> nb) {
-        nb.begin(array.length);
-        for (Integer i : array) {
-            nb.apply(i);
-        }
-        nb.end();
-        return nb.build();
-    }
-
-    Node<Integer> degenerateTree(Iterator<Integer> it) {
-        if (!it.hasNext()) {
-            return Nodes.node(Collections.<Integer>emptyList());
-        }
-
-        Integer i = it.next();
-        if (it.hasNext()) {
-            return Nodes.node(Nodes.node(new Integer[]{i}), degenerateTree(it));
-        }
-        else {
-            return Nodes.node(new Integer[]{i});
-        }
-    }
-
-    Node<Integer> tree(List<Integer> l, Function<Node<Integer>, List<Integer>> m) {
-        if (l.size() < 3) {
-            return m.apply(l);
-        }
-        else {
-            return Nodes.node(tree(l.subList(0, l.size() / 2), m), tree(l.subList(l.size() / 2, l.size()), m));
-        }
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testAsArray(Integer[] array, Node<Integer> n) {
-        assertEquals(n.asArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testFlattenAsArray(Integer[] array, Node<Integer> n) {
-        assertEquals(n.flatten().asArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testCopyTo(Integer[] array, Node<Integer> n) {
-        Integer[] copy = new Integer[n.size()];
-        n.copyInto(copy, 0);
-
-        assertEquals(copy, array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testForEach(Integer[] array, Node<Integer> n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        n.forEach(e -> {
-            l.add(e);
-        });
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testIterator(Integer[] array, Node<Integer> n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        Iterator<Integer> it = n.iterator();
-        while (it.hasNext()) {
-            l.add(it.next());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testRootSpliterator(Integer[] array, Node<Integer> n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        Iterator<Integer> it = n.spliterator().iterator();
-        while (it.hasNext()) {
-            l.add(it.next());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testDepthOneSpliterator(Integer[] array, Node<Integer> n) {
-        List<Integer> l = new ArrayList<>(n.size());
-
-        Spliterator<Integer> s = n.spliterator();
-        for (int i = 0; i < s.getNaturalSplits(); i++) {
-            Iterator<Integer> it = s.split().iterator();
-            while (it.hasNext()) {
-                l.add(it.next());
-            }
-        }
-
-        Iterator<Integer> it = s.iterator();
-        while (it.hasNext()) {
-            l.add(it.next());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testTwoSpliterator(Integer[] array, Node<Integer> n) {
-        List<Integer> l = new ArrayList<>(n.size());
-
-        Spliterator<Integer> s2 = n.spliterator();
-        Spliterator<Integer> s1 = s2.split();
-
-        Iterator<Integer> it = s1.iterator();
-        while (it.hasNext()) {
-            l.add(it.next());
-        }
-
-        it = s2.iterator();
-        while (it.hasNext()) {
-            l.add(it.next());
-        }
-
-        assertEquals(l.toArray(), array);
-    }
-
-    @Test(dataProvider = "nodes")
-    public void testSpliterator(Integer[] array, Node<Integer> n) {
-        List<Integer> l = new ArrayList<>(n.size());
-        split(l, n.spliterator());
-
-        assertEquals(l.toArray(), array);
-    }
-
-    void split(List<Integer> l, Spliterator<Integer> s) {
-        if (s.getNaturalSplits() == 0) {
-            Spliterator<Integer> _s = s.split();
-            assertEquals(_s.getNaturalSplits(), 0);
-            assertFalse(_s.split().iterator().hasNext());
-
-            s.forEach(e -> {
-                l.add(e);
-            });
-        }
-        else {
-            int size = s.getSizeIfKnown();
-            for (int i = 0; i < s.getNaturalSplits(); i++) {
-                Spliterator<Integer> _s = s.split();
-                split(l, _s);
-            }
-
-            assertTrue(s.getSizeIfKnown() < size);
-
-            split(l, s);
-        }
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/PrimitiveOpsTests.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.primitive.*;
-
-@Test
-public class PrimitiveOpsTests {
-
-    public void testSum() {
-        int sum = Primitives.range(1, 10).filter(i -> i % 2 == 0).sum();
-        Assert.assertEquals(sum, 20);
-    }
-
-    public void testMap() {
-        int sum = Primitives.range(1, 10).filter(i -> i % 2 == 0).map(i -> i * 2).sum();
-        Assert.assertEquals(sum, 40);
-    }
-
-    public void testParSum() {
-        int sum = Primitives.parRange(1, 10).filter(i -> i % 2 == 0).sum();
-        Assert.assertEquals(sum, 20);
-    }
-
-    public void testSumPull() {
-        IntStream s = Primitives.range(1, 10).filter(i -> i % 2 == 0);
-
-        IntIterator ii = s.iterator();
-        int i = ii.nextInt();
-
-        Assert.assertEquals(s.sum() + i, 20);
-    }
-
-    public void testTee() {
-        int[] teeSum = new int[1];
-        int sum = Primitives.range(1, 10).filter(i -> i % 2 == 0).tee(i -> { teeSum[0] = teeSum[0] + i; }).sum();
-        Assert.assertEquals(teeSum[0], sum);
-    }
-
-    public void testForEach() {
-        int[] sum = new int[1];
-        Primitives.range(1, 10).filter(i -> i % 2 == 0).forEach(i -> { sum[0] = sum[0] + i; });
-        Assert.assertEquals(sum[0], 20);
-    }
-
-    public void testParForEach() {
-        AtomicInteger ai = new AtomicInteger(0);
-        Primitives.parRange(1, 10).filter(i -> i % 2 == 0).forEach(i -> { ai.addAndGet(i); });
-        Assert.assertEquals(ai.get(), 20);
-    }
-
-    public void testBox() {
-        List<Integer> l = Primitives.parRange(1, 10).boxed().into(new ArrayList<Integer>());
-        int sum = l.stream().reduce(0, (a, b) -> a + b);
-        Assert.assertEquals(sum, 45);
-    }
-
-    public void testUnBox() {
-       int sum = Arrays.asList(1, 2, 3, 4, 5).stream().map(i -> (int) i).sum();
-        Assert.assertEquals(sum, 15);
-    }
-
-    public void testToArray() {
-        {
-            int[] array =  Primitives.range(1, 10).map(i -> i * 2).toArray();
-            Assert.assertEquals(array, new int[] {2, 4, 6, 8, 10, 12, 14, 16, 18});
-        }
-
-        {
-            int[] array =  Primitives.parRange(1, 10).map(i -> i * 2).toArray();
-            Assert.assertEquals(array, new int[] {2, 4, 6, 8, 10, 12, 14, 16, 18});
-        }
-    }
-
-    public void testSort() {
-        Random r = new Random();
-
-        int[] content = Primitives.repeatedly(10, () -> r.nextInt(100)).toArray();
-        int[] sortedContent = content.clone();
-        Arrays.sort(sortedContent);
-
-        {
-            int[] array =  Primitives.stream(content).sorted().toArray();
-            Assert.assertEquals(array, sortedContent);
-        }
-
-        {
-            int[] array =  Primitives.parallel(content).sorted().toArray();
-            Assert.assertEquals(array, sortedContent);
-        }
-    }
-
-    public void testSortSort() {
-        Random r = new Random();
-
-        int[] content = Primitives.repeatedly(10, () -> r.nextInt(100)).toArray();
-        int[] sortedContent = content.clone();
-        Arrays.sort(sortedContent);
-
-        {
-            int[] array =  Primitives.stream(content).sorted().sorted().toArray();
-            Assert.assertEquals(array, sortedContent);
-        }
-
-        {
-            int[] array =  Primitives.parallel(content).sorted().sorted().toArray();
-            Assert.assertEquals(array, sortedContent);
-        }
-    }
-
-    public void testSequential() {
-
-        int[] expected = Primitives.range(1, 1000).toArray();
-
-        {
-            IntNodeBuilder nb = IntNodes.makeVariableSizeBuilder();
-            Primitives.range(1, 1000).sequential().forEach(nb);
-            Assert.assertTrue(Arrays.equals(expected, nb.build().asIntArray()));
-        }
-
-        {
-            IntNodeBuilder nb = IntNodes.makeVariableSizeBuilder();
-            Primitives.parRange(1, 1000).sequential().forEach(nb);
-            Assert.assertTrue(Arrays.equals(expected, nb.build().asIntArray()));
-        }
-    }
-
-    public void testLimit() {
-        int[] expected = Primitives.range(1, 10).toArray();
-
-        {
-            int[] actual = Primitives.iterate(1, i -> i + 1).limit(9).toArray();
-            Assert.assertTrue(Arrays.equals(expected, actual));
-        }
-
-        {
-            int[] actual = Primitives.parRange(1, 100).limit(9).toArray();
-            Assert.assertTrue(Arrays.equals(expected, actual));
-        }
-    }
-
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceByOpTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamTestDataProvider;
-import org.testng.annotations.Test;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.function.Functions;
-import java.util.stream.op.GroupByOp;
-import java.util.stream.op.ReduceByOp;
-
-import static org.openjdk.tests.java.util.LambdaTestHelpers.*;
-
-/**
- * ReduceByOpTest
- *
- * @author Brian Goetz
- */
-@Test
-public class ReduceByOpTest extends OpTestCase {
-
-    @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
-    public void testOps(String name, StreamTestData<Integer> data) {
-        Map<Boolean,Collection<Integer>> gbResult = data.stream().groupBy(Functions.forPredicate(pEven, true, false));
-        Map<Boolean,Integer> result = data.stream().reduceBy(Functions.forPredicate(pEven, true, false),
-                                                                () -> 0, rPlus, rPlus);
-        assertEquals(result.size(), gbResult.size());
-        for (Map.Entry<Boolean, Integer> entry : result.entrySet())
-            assertEquals(entry.getValue(), data.stream().filter(e -> pEven.test(e) == entry.getKey()).reduce(0, rPlus));
-
-        int uniqueSize = data.into(new HashSet<Integer>()).size();
-        Map<Integer, Collection<Integer>> mgResult = exerciseOps(data, new GroupByOp<>(mId));
-        Map<Integer, Integer> miResult = exerciseOps(data, new ReduceByOp<Integer, Integer, Integer>(mId, () -> 0, (w, t) -> w + 1, (w, u) -> w + u));
-        assertEquals(miResult.keySet().size(), uniqueSize);
-        for (Map.Entry<Integer, Integer> entry : miResult.entrySet())
-            assertEquals((int) entry.getValue(), mgResult.get(entry.getKey()).size());
-    }
-}
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceTest.java	Thu Nov 15 22:03:04 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util.stream.op;
-
-import org.openjdk.tests.java.util.stream.OpTestCase;
-import org.openjdk.tests.java.util.stream.StreamTestData;
-import org.openjdk.tests.java.util.stream.StreamT