groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch GROOVY_2_5_X updated: more consistent JDK version checking in tests
Date Wed, 17 Apr 2019 10:47:03 GMT
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


The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
     new 24f10d3  more consistent JDK version checking in tests
24f10d3 is described below

commit 24f10d3e9c3f0de976902f9274af3a48133220e4
Author: Paul King <paulk@asert.com.au>
AuthorDate: Wed Apr 17 20:44:59 2019 +1000

    more consistent JDK version checking in tests
---
 .../groovy/runtime/InterfaceConversionTest.groovy  | 118 ++++++++++-----------
 1 file changed, 58 insertions(+), 60 deletions(-)

diff --git a/src/test/org/codehaus/groovy/runtime/InterfaceConversionTest.groovy b/src/test/org/codehaus/groovy/runtime/InterfaceConversionTest.groovy
index 614948f..30bcc93 100644
--- a/src/test/org/codehaus/groovy/runtime/InterfaceConversionTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/InterfaceConversionTest.groovy
@@ -1,61 +1,59 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.codehaus.groovy.runtime
-
-class InterfaceConversionTest extends GroovyTestCase {
-
-    void testClosureConversion() {
-        def c1 = { Object[] args -> args?.length }
-        def c2 = c1 as InterfaceConversionTestFoo
-        assert !(c1 instanceof InterfaceConversionTestFoo)
-        assert c2 instanceof InterfaceConversionTestFoo
-        assert c2.a() == 0
-        assert c2.b(null) == null
-    }
-
-    void testMapConversion() {
-        def m1 = [a: { 1 }, b: { 2 }]
-        def m2 = m1 as InterfaceConversionTestFoo
-
-        assert !(m1 instanceof InterfaceConversionTestFoo)
-        assert m2 instanceof InterfaceConversionTestFoo
-        assert m2.a() == 1
-        assert m2.b(null) == 2
-    }
-
-    //GROOVY-7104
-    void testDefaultInterfaceMethodCallOnProxy() {
-        try {
-            // checks for Java 8
-            Class.forName("java.util.function.Consumer", false, this.class.classLoader)
-        } catch (ignore) {
-            return
-        }
-        Comparator c1 = { a, b -> a <=> b }
-        assert c1.compare("a", "b") == -1
-        def c2 = c1.reversed()
-        assert c2.compare("a", "b") == 1
-    }
-}
-
-interface InterfaceConversionTestFoo {
-    def a()
-
-    def b(Integer i)
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.runtime
+
+import static groovy.test.GroovyAssert.isAtLeastJdk
+
+class InterfaceConversionTest extends GroovyTestCase {
+
+    void testClosureConversion() {
+        def c1 = { Object[] args -> args?.length }
+        def c2 = c1 as InterfaceConversionTestFoo
+        assert !(c1 instanceof InterfaceConversionTestFoo)
+        assert c2 instanceof InterfaceConversionTestFoo
+        assert c2.a() == 0
+        assert c2.b(null) == null
+    }
+
+    void testMapConversion() {
+        def m1 = [a: { 1 }, b: { 2 }]
+        def m2 = m1 as InterfaceConversionTestFoo
+
+        assert !(m1 instanceof InterfaceConversionTestFoo)
+        assert m2 instanceof InterfaceConversionTestFoo
+        assert m2.a() == 1
+        assert m2.b(null) == 2
+    }
+
+    //GROOVY-7104
+    void testDefaultInterfaceMethodCallOnProxy() {
+        // reversed is a default method within the Comparator interface for 1.8+
+        if (!isAtLeastJdk("1.8")) return
+        Comparator c1 = { a, b -> a <=> b }
+        assert c1.compare("a", "b") == -1
+        def c2 = c1.reversed()
+        assert c2.compare("a", "b") == 1
+    }
+}
+
+interface InterfaceConversionTestFoo {
+    def a()
+
+    def b(Integer i)
 }
\ No newline at end of file


Mime
View raw message