You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/05/26 14:38:25 UTC

[4/4] groovy git commit: GROOVY-8601: port test/doco example tests back to pre-Parrot style

GROOVY-8601: port test/doco example tests back to pre-Parrot style


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3b6d1f52
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3b6d1f52
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3b6d1f52

Branch: refs/heads/GROOVY_2_5_X
Commit: 3b6d1f5227c5750b279b8ac5d7b9487f96fcbb68
Parents: 74116c0
Author: Daniel Sun <re...@hotmail.com>
Authored: Sun May 27 00:37:51 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sun May 27 00:37:51 2018 +1000

----------------------------------------------------------------------
 .../groovy-test-junit5/src/spec/test/MyTestViaRun.groovy    | 9 +++------
 .../groovy-test-junit5/src/test/groovy/MyTestJunit5.groovy  | 9 +++------
 2 files changed, 6 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/3b6d1f52/subprojects/groovy-test-junit5/src/spec/test/MyTestViaRun.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-test-junit5/src/spec/test/MyTestViaRun.groovy b/subprojects/groovy-test-junit5/src/spec/test/MyTestViaRun.groovy
index 17b4b32..f5bcc74 100644
--- a/subprojects/groovy-test-junit5/src/spec/test/MyTestViaRun.groovy
+++ b/subprojects/groovy-test-junit5/src/spec/test/MyTestViaRun.groovy
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.*
 import org.junit.jupiter.params.ParameterizedTest
 import org.junit.jupiter.params.provider.ValueSource
 import java.util.stream.Stream
-import static org.junit.jupiter.api.Assertions.assertTrue
 import static org.junit.jupiter.api.DynamicTest.dynamicTest
 import java.util.logging.ConsoleHandler
 import java.util.logging.Level
@@ -46,14 +45,12 @@ class MyTest {
 // tag::junit5_test_part2[]
   @Test
   void streamSum() {
-    assertTrue(Stream.of(1, 2, 3)
-      .mapToInt(i -> i)
-      .sum() > 5, () -> "Sum should be greater than 5")
+    assert Stream.of(1, 2, 3).mapToInt{ i -> i }.sum() > 5
   }
 
   @RepeatedTest(value=2, name = "{displayName} {currentRepetition}/{totalRepetitions}")
   void streamSumRepeated() {
-    assert Stream.of(1, 2, 3).mapToInt(i -> i).sum() == 6
+    assert Stream.of(1, 2, 3).mapToInt{i -> i}.sum() == 6
   }
 
   private boolean isPalindrome(s) { s == s.reverse()  }
@@ -67,7 +64,7 @@ class MyTest {
   @TestFactory
   def dynamicTestCollection() {[
     dynamicTest("Add test") { -> assert 1 + 1 == 2 },
-    dynamicTest("Multiply Test", () -> { assert 2 * 3 == 6 })
+    dynamicTest("Multiply Test") { -> assert 2 * 3 == 6 }
   ]}
 }
 // end::junit5_test_part2[]

http://git-wip-us.apache.org/repos/asf/groovy/blob/3b6d1f52/subprojects/groovy-test-junit5/src/test/groovy/MyTestJunit5.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-test-junit5/src/test/groovy/MyTestJunit5.groovy b/subprojects/groovy-test-junit5/src/test/groovy/MyTestJunit5.groovy
index 69317b3..aae0a36 100644
--- a/subprojects/groovy-test-junit5/src/test/groovy/MyTestJunit5.groovy
+++ b/subprojects/groovy-test-junit5/src/test/groovy/MyTestJunit5.groovy
@@ -3,21 +3,18 @@ import org.junit.jupiter.api.*
 import org.junit.jupiter.params.ParameterizedTest
 import org.junit.jupiter.params.provider.ValueSource
 import java.util.stream.Stream
-import static org.junit.jupiter.api.Assertions.assertTrue
 import static org.junit.jupiter.api.DynamicTest.dynamicTest
 
 class MyTestJUnit5 {
 
   @Test
   void streamSum() {
-    assertTrue(Stream.of(1, 2, 3)
-      .mapToInt(i -> i)
-      .sum() > 5, () -> "Sum should be greater than 5")
+    assert Stream.of(1, 2, 3).mapToInt{ i -> i }.sum() > 5
   }
 
   @RepeatedTest(value=2, name = "{displayName} {currentRepetition}/{totalRepetitions}")
   void streamSumRepeated() {
-    assert Stream.of(1, 2, 3).mapToInt(i -> i).sum() == 6
+    assert Stream.of(1, 2, 3).mapToInt{ i -> i }.sum() == 6
   }
 
   private boolean isPalindrome(s) { s == s.reverse()  }
@@ -31,6 +28,6 @@ class MyTestJUnit5 {
   @TestFactory
   def dynamicTestCollection() {[
     dynamicTest("Add test") { -> assert 1 + 1 == 2 },
-    dynamicTest("Multiply Test", () -> { assert 2 * 3 == 6 })
+    dynamicTest("Multiply Test") { -> assert 2 * 3 == 6 }
   ]}
 }