changeset 6634:a269130fad70

Adjust lambda syntax in tests now that compiler restriction has been lifted on value-bearing bodies in void lambdas; remove tests of bound static method references now that these are disallowed
author briangoetz
date Tue, 27 Nov 2012 11:32:03 -0500
parents a296f32dd813
children 10b4ad05eafe
files test-ng/tests/org/openjdk/tests/java/util/LambdaTestHelpers.java test-ng/tests/org/openjdk/tests/java/util/stream/SpliteratorTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/ForEachOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.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/SliceOpTest.java test-ng/tests/org/openjdk/tests/java/util/stream/op/TeeOpTest.java test-ng/tests/org/openjdk/tests/javac/MethodReferenceTestKinds.java test-ng/tests/org/openjdk/tests/separate/Compiler.java test-ng/tests/org/openjdk/tests/vm/FDSeparateCompilationTest.java
diffstat 12 files changed, 18 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/test-ng/tests/org/openjdk/tests/java/util/LambdaTestHelpers.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/LambdaTestHelpers.java	Tue Nov 27 11:32:03 2012 -0500
@@ -53,7 +53,7 @@
     public static final Function<Integer, Integer> mZero = x -> 0;
     public static final Function<Integer, Integer> mId = x -> x;
     public static final Function<Integer, Integer> mDoubler = x -> x * 2;
-    public static final FlatMapper<Integer, Integer> mfId = /*@@@ Sink::accept*/ (s,e) -> { s.accept(e); };
+    public static final FlatMapper<Integer, Integer> mfId = /*@@@ Sink::accept*/ (s,e) -> s.accept(e);
     public static final FlatMapper<Integer, Integer> mfNull = (s, e) -> { };
     public static final FlatMapper<Integer, Integer> mfLt = (s, e) -> { for (int i=0; i<e; i++) s.accept(i); };
     public static final IntFunction<Integer> imDoubler = x -> x * 2;
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/SpliteratorTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/SpliteratorTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -52,7 +52,7 @@
         while (iterator.hasNext())
             fromIterator.add(iterator.next());
         ArrayList<Integer> fromForEach = new ArrayList<>();
-        supplier.get().forEach(e -> { fromForEach.add(e); });
+        supplier.get().forEach(e -> fromForEach.add(e));
 
         // assert that size, iterator, and forEach are consistent
         if (sizeIfKnown >= 0) {
@@ -73,14 +73,14 @@
             fromIterator.add(iterator.next());
 
         // Assert that forEach now produces no elements
-        iterator.forEach(e -> { fail("Iterator.forEach produced an element after iterator exhausted"); });
+        iterator.forEach(e -> fail("Iterator.forEach produced an element after iterator exhausted"));
 
         // Iterate first few elements, then forEach rest
         ArrayList<Integer> dest = new ArrayList<>();
         iterator = supplier.get().iterator();
         for (int i=0; i<10 && iterator.hasNext(); i++)
             dest.add(iterator.next());
-        iterator.forEach(e -> { dest.add(e); });
+        iterator.forEach(e -> dest.add(e));
 
         if (sizeIfKnown >= 0)
             assertEquals(sizeIfKnown, dest.size());
@@ -128,7 +128,7 @@
                     dest.add(iterator.next());
                 }
                 // Assert that Iterator.forEach now produces no elements
-                iterator.forEach(e -> { fail("Iterator.forEach produced an element after iterator exhausted"); });
+                iterator.forEach(e -> fail("Iterator.forEach produced an element after iterator exhausted"));
 
                 if (sizeIfKnown >= 0)
                     assertEquals(sizeIfKnown, count);
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/ForEachOpTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/ForEachOpTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -53,9 +53,7 @@
         exerciseTerminalOps(countTo(10),
                             s -> {
                                 AtomicInteger count = new AtomicInteger(0);
-                                s.forEach(e -> {
-                                    count.incrementAndGet();
-                                });
+                                s.forEach(e -> count.incrementAndGet());
                                 return count.get();
                             },
                             10);
@@ -63,9 +61,7 @@
         exerciseTerminalOps(countTo(10),
                             s -> {
                                 AtomicInteger sum = new AtomicInteger(0);
-                                s.forEach(e -> {
-                                    sum.addAndGet(e);
-                                });
+                                s.forEach(e -> sum.addAndGet(e));
                                 return sum.get();
                             },
                             55);
@@ -76,9 +72,7 @@
     public void testOps(String name, StreamTestData<Integer> data) {
         withData(data).terminal(s -> {
             List<Integer> l = Collections.synchronizedList(new ArrayList<Integer>());
-            s.forEach(e -> {
-                l.add(e);
-            });
+            s.forEach(e -> l.add(e));
             return l;
         }).parallelEqualator(LambdaTestHelpers::equalsContentsUnordered).exercise();
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/IntNodeTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -141,9 +141,7 @@
     @Test(dataProvider = "nodes")
     public void testForEach(int[] array, IntNode n) {
         List<Integer> l = new ArrayList<>(n.size());
-        n.forEach(e -> {
-            l.add(e);
-        });
+        n.forEach(e -> l.add(e));
 
         assertEquals(l.toArray(), array);
     }
@@ -224,9 +222,7 @@
             assertEquals(_s.getNaturalSplits(), 0);
             assertFalse(_s.split().iterator().hasNext());
 
-            s.forEach(e -> {
-                l.add(e);
-            });
+            s.forEach(e -> l.add(e));
         }
         else {
             int size = s.getSizeIfKnown();
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeBuilderTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeBuilderTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -83,9 +83,7 @@
 
         {
             List<Integer> _l = new ArrayList<>();
-            nb.forEach(e -> {
-                _l.add(e);
-            });
+            nb.forEach(e -> _l.add(e));
 
             assertContents(_l, l);
         }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/NodeTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -127,9 +127,7 @@
     @Test(dataProvider = "nodes")
     public void testForEach(Integer[] array, Node<Integer> n) {
         List<Integer> l = new ArrayList<>(n.size());
-        n.forEach(e -> {
-            l.add(e);
-        });
+        n.forEach(e -> l.add(e));
 
         assertEquals(l.toArray(), array);
     }
@@ -210,9 +208,7 @@
             assertEquals(_s.getNaturalSplits(), 0);
             assertFalse(_s.split().iterator().hasNext());
 
-            s.forEach(e -> {
-                l.add(e);
-            });
+            s.forEach(e -> l.add(e));
         }
         else {
             int size = s.getSizeIfKnown();
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/PrimitiveOpsTests.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/PrimitiveOpsTests.java	Tue Nov 27 11:32:03 2012 -0500
@@ -66,7 +66,7 @@
 
     public void testParForEach() {
         AtomicInteger ai = new AtomicInteger(0);
-        Primitives.parRange(1, 10).filter(i -> i % 2 == 0).forEach(i -> { ai.addAndGet(i); });
+        Primitives.parRange(1, 10).filter(i -> i % 2 == 0).forEach(i -> ai.addAndGet(i));
         Assert.assertEquals(ai.get(), 20);
     }
 
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/SliceOpTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/SliceOpTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -203,7 +203,7 @@
         for (int l : Arrays.asList(0, 10)) {
             AtomicInteger ai = new AtomicInteger();
             countTo(100).stream()
-                    .tee(i -> { ai.getAndIncrement(); })
+                    .tee(i -> ai.getAndIncrement())
                     .limit(l).toArray();
             assertEquals(ai.get(), l, "tee block was called too many times");
         }
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/TeeOpTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/TeeOpTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -44,9 +44,7 @@
  */
 public class TeeOpTest extends OpTestCase {
     private <T> Block<T> asBlock(List<T> l) {
-        return t -> {
-            l.add(t);
-        };
+        return t -> l.add(t);
     }
 
     public void testRawIterator() {
--- a/test-ng/tests/org/openjdk/tests/javac/MethodReferenceTestKinds.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/javac/MethodReferenceTestKinds.java	Tue Nov 27 11:32:03 2012 -0500
@@ -114,20 +114,6 @@
 	assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
     }
 
-    public void testMRStaticEval() {
-	MethodReferenceTestKinds evalCheck;
-	S0 var = (evalCheck = inst("discard"))::staticMethod0;
-	assertEquals(evalCheck.toString(), "MethodReferenceTestKinds(discard)");
-	assertEquals(var.get(), "SM:0");
-    }
-
-    public void testMRStaticEvalArg() {
-	MethodReferenceTestKinds evalCheck;
-	S1 var = (evalCheck = inst("discard"))::staticMethod1;
-	assertEquals(evalCheck.toString(), "MethodReferenceTestKinds(discard)");
-	assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
-    }
-
     public void testMRTopLevel() {
 	SN0 var = MethodReferenceTestKindsBase::new;
 	assertEquals(var.make().toString(), "MethodReferenceTestKindsBase(blank)");
--- a/test-ng/tests/org/openjdk/tests/separate/Compiler.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/separate/Compiler.java	Tue Nov 27 11:32:03 2012 -0500
@@ -156,8 +156,7 @@
             }
         }
         List<JavaFileObject> files = new ArrayList<>();
-        SourceProcessor accum = 
-            (name, src) -> { files.add(new SourceFile(name, src)); };
+        SourceProcessor accum = (name, src) -> files.add(new SourceFile(name, src));
 
         for (Type dep : type.typeDependencies()) {
             dep.generateAsDependency(accum, type.methodDependencies());
--- a/test-ng/tests/org/openjdk/tests/vm/FDSeparateCompilationTest.java	Tue Nov 27 12:04:42 2012 +0100
+++ b/test-ng/tests/org/openjdk/tests/vm/FDSeparateCompilationTest.java	Tue Nov 27 11:32:03 2012 -0500
@@ -130,7 +130,7 @@
     private void printCaseDetails(Hierarchy hs) {
         String exp = getExpectedResult(hs.root);
         hs.getDescription().forEach(
-                x -> { System.out.println("    " + x); });
+                x -> System.out.println("    " + x));
         if (exp != null) { 
             System.out.println("    Expected \"" + exp + "\"");
         } else {