changeset 5881:794edf7559b2 it2-bootstrap

Merge
author briangoetz
date Thu, 30 Aug 2012 19:42:31 -0400
parents 76ff1fc6f813 be97f25c86f1
children 96417b3ae0e1
files test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceTest.java
diffstat 1 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceTest.java	Thu Aug 30 19:40:53 2012 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceTest.java	Thu Aug 30 19:42:31 2012 -0400
@@ -28,6 +28,7 @@
 import org.testng.annotations.Test;
 
 import java.util.List;
+import java.util.Optional;
 import java.util.streams.ops.FoldOp;
 import java.util.streams.ops.MapOp;
 import java.util.streams.ops.SeedlessFoldOp;
@@ -59,20 +60,28 @@
 
     @Test(dataProvider = "opArrays", dataProviderClass = StreamTestDataProvider.class)
     public void testOps(String name, TestData<Integer> data) {
-        exerciseOps(data, new SeedlessFoldOp<>(rPlus));
-        exerciseOps(data, new SeedlessFoldOp<>(rMin));
-        exerciseOps(data, new SeedlessFoldOp<>(rMax));
+        Optional<Integer> seedless = exerciseOps(data, new SeedlessFoldOp<>(rPlus));
+        Integer folded = exerciseOps(data, new FoldOp<>(() -> 0, rPlus, rPlus));
+        assertEquals(folded, seedless.orElse(0));
 
-        exerciseOps(data, new SeedlessFoldOp<>(rPlus), new MapOp<>(mDoubler));
-        exerciseOps(data, new SeedlessFoldOp<>(rMin), new MapOp<>(mDoubler));
-        exerciseOps(data, new SeedlessFoldOp<>(rMax), new MapOp<>(mDoubler));
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rMin));
+        folded = exerciseOps(data, new FoldOp<>(() -> Integer.MAX_VALUE, rMin, rMin));
+        assertEquals(folded, seedless.orElse(Integer.MAX_VALUE));
 
-        exerciseOps(data, new FoldOp<>(() -> 0, rPlus, rPlus));
-        exerciseOps(data, new FoldOp<>(() -> 0, rMin, rMin));
-        exerciseOps(data, new FoldOp<>(() -> 0, rMax, rMax));
+        seedless = exerciseOps(data, new SeedlessFoldOp<>(rMax));
+        folded = exerciseOps(data, new FoldOp<>(() -> Integer.MIN_VALUE, rMax, rMax));
+        assertEquals(folded, seedless.orElse(Integer.MIN_VALUE));
 
-        exerciseOps(data, new FoldOp<>(() -> 0, rPlus, rPlus), new MapOp<>(mDoubler));
-        exerciseOps(data, new FoldOp<>(() -> 0, rMin, rMin), new MapOp<>(mDoubler));
-        exerciseOps(data, new FoldOp<>(() -> 0, rMax, rMax), new MapOp<>(mDoubler));
+        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));
     }
 }