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 2019/04/17 01:35:28 UTC

[groovy] 01/02: add an additional test method

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit cc32fe3e13d2d37b1ccfb45cc7dd6804105dc19b
Author: Paul King <pa...@asert.com.au>
AuthorDate: Wed Apr 17 11:00:14 2019 +1000

    add an additional test method
---
 .../src/main/java/groovy/test/GroovyAssert.java            | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java b/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java
index 831f64a..917fed0 100644
--- a/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java
+++ b/subprojects/groovy-test/src/main/java/groovy/test/GroovyAssert.java
@@ -26,6 +26,7 @@ import org.junit.Test;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.math.BigDecimal;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Logger;
 
@@ -333,6 +334,19 @@ public class GroovyAssert extends org.junit.Assert {
         return true;
     }
 
+    /**
+     * @return true if the JDK version is at least the version given by specVersion (e.g. "1.8", "9.0")
+     * @since 2.5.7
+     */
+    public static boolean isAtLeastJdk(String specVersion) {
+        boolean result = false;
+        try {
+            result = new BigDecimal(System.getProperty("java.specification.version")).compareTo(new BigDecimal(specVersion)) >= 0;
+        } catch (Exception ignore) {
+        }
+        return result;
+    }
+
     private static String buildExceptionList(Throwable th) {
         StringBuilder sb = new StringBuilder();
         int level = 0;