From commits-return-8310-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Wed Apr 17 10:47:04 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 14448180672 for ; Wed, 17 Apr 2019 12:47:03 +0200 (CEST) Received: (qmail 78212 invoked by uid 500); 17 Apr 2019 10:47:03 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 78198 invoked by uid 99); 17 Apr 2019 10:47:03 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Apr 2019 10:47:03 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 49BE18A0AB; Wed, 17 Apr 2019 10:47:03 +0000 (UTC) Date: Wed, 17 Apr 2019 10:47:03 +0000 To: "commits@groovy.apache.org" Subject: [groovy] branch GROOVY_2_5_X updated: more consistent JDK version checking in tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155549802317.21597.5818481874741068856@gitbox.apache.org> From: paulk@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: groovy X-Git-Refname: refs/heads/GROOVY_2_5_X X-Git-Reftype: branch X-Git-Oldrev: 7cf9afd6f28f41081e16fe570e6d18173040335f X-Git-Newrev: 24f10d3e9c3f0de976902f9274af3a48133220e4 X-Git-Rev: 24f10d3e9c3f0de976902f9274af3a48133220e4 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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