changeset 5879:be97f25c86f1 it2-bootstrap

compare seedless against regular fold.
author mduigou
date Thu, 30 Aug 2012 12:35:24 -0700
parents 9dd0188c1229
children 794edf7559b2
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 11:42:29 2012 -0400
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/ops/ReduceTest.java	Thu Aug 30 12:35:24 2012 -0700
@@ -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(folded));
 
-        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(folded));
 
-        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(folded));
 
-        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(folded));
+
+        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(folded));
+
+        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(folded));
     }
 }