From commits-return-9567-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Fri Nov 1 16:45:41 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 3F41718067A for ; Fri, 1 Nov 2019 17:45:40 +0100 (CET) Received: (qmail 55523 invoked by uid 500); 1 Nov 2019 16:45:39 -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 55347 invoked by uid 99); 1 Nov 2019 16:45:39 -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; Fri, 01 Nov 2019 16:45:39 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 18F5880A97; Fri, 1 Nov 2019 16:45:39 +0000 (UTC) Date: Fri, 01 Nov 2019 16:45:44 +0000 To: "commits@groovy.apache.org" Subject: [groovy] 06/09: GROOVY-8457: use ClassHelper.make(Class) for resolved exception type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: sunlan@apache.org In-Reply-To: <157262673872.25245.13587741766835039188@gitbox.apache.org> References: <157262673872.25245.13587741766835039188@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: groovy X-Git-Refname: refs/heads/GROOVY_3_0_X X-Git-Reftype: branch X-Git-Rev: dd3a64f3a0546f6626982bc5ba8f68e43d27631e X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191101164539.18F5880A97@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch GROOVY_3_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git commit dd3a64f3a0546f6626982bc5ba8f68e43d27631e Author: Eric Milles AuthorDate: Thu Oct 31 20:17:18 2019 -0500 GROOVY-8457: use ClassHelper.make(Class) for resolved exception type (cherry picked from commit 1437642286adfc0b892f34abc1ad2738b6ea8595) --- .../NotYetImplementedASTTransformation.java | 3 +- .../NotYetImplementedTransformTest.groovy | 43 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/subprojects/groovy-test/src/main/java/org/apache/groovy/test/transform/NotYetImplementedASTTransformation.java b/subprojects/groovy-test/src/main/java/org/apache/groovy/test/transform/NotYetImplementedASTTransformation.java index 2b8cba3..7c6250c 100644 --- a/subprojects/groovy-test/src/main/java/org/apache/groovy/test/transform/NotYetImplementedASTTransformation.java +++ b/subprojects/groovy-test/src/main/java/org/apache/groovy/test/transform/NotYetImplementedASTTransformation.java @@ -33,6 +33,7 @@ import org.codehaus.groovy.transform.AbstractASTTransformation; import org.codehaus.groovy.transform.GroovyASTTransformation; import java.util.Arrays; +import junit.framework.AssertionFailedError; import static org.codehaus.groovy.ast.tools.GeneralUtils.args; import static org.codehaus.groovy.ast.tools.GeneralUtils.block; @@ -52,7 +53,7 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.tryCatchS; public class NotYetImplementedASTTransformation extends AbstractASTTransformation { private static final ClassNode CATCH_TYPE = ClassHelper.make(Throwable.class); - private static final ClassNode THROW_TYPE = ClassHelper.make("junit.framework.AssertionFailedError"); // TODO: java.lang.AssertionError + private static final ClassNode THROW_TYPE = ClassHelper.make(AssertionFailedError.class); // TODO: java.lang.AssertionError public void visit(ASTNode[] nodes, SourceUnit source) { if (!(nodes.length == 2 && nodes[0] instanceof AnnotationNode && nodes[1] instanceof MethodNode)) { diff --git a/subprojects/groovy-test/src/test/groovy/org/apache/groovy/test/transform/NotYetImplementedTransformTest.groovy b/subprojects/groovy-test/src/test/groovy/org/apache/groovy/test/transform/NotYetImplementedTransformTest.groovy index 99314d9..f6eef26 100644 --- a/subprojects/groovy-test/src/test/groovy/org/apache/groovy/test/transform/NotYetImplementedTransformTest.groovy +++ b/subprojects/groovy-test/src/test/groovy/org/apache/groovy/test/transform/NotYetImplementedTransformTest.groovy @@ -117,6 +117,27 @@ final class NotYetImplementedTransformTest { assert output.wasSuccessful() : '@Test method marked with @NotYetImplemented must NOT throw an AssertionFailedError' } + @Test // GROOVY-8457 + void testNotYetImplementedJUnit4Failure_atCompileStatic() { + def output = shell.evaluate(''' + import groovy.transform.CompileStatic + import groovy.test.NotYetImplemented + import org.junit.Test + import org.junit.runner.JUnitCore + + @CompileStatic + class MyTests { + @NotYetImplemented @Test void testThatFails() { + assert false + } + } + + new JUnitCore().run(MyTests) + ''') + + assert output.wasSuccessful() : '@Test method marked with @CompileStatic and @NotYetImplemented must NOT throw an AssertionFailedError' + } + @Test void testNotYetImplementedJUnit4Success() { def output = shell.evaluate(''' @@ -137,4 +158,26 @@ final class NotYetImplementedTransformTest { assert output.failureCount == 1 : '@Test method marked with @NotYetImplemented must throw an AssertionFailedError' assert output.failures.first().exception instanceof AssertionFailedError : '@Test method marked with @NotYetImplemented must throw an AssertionFailedError' } + + @Test // GROOVY-8457 + void testNotYetImplementedJUnit4Success_atCompileStatic() { + def output = shell.evaluate(''' + import groovy.transform.CompileStatic + import groovy.test.NotYetImplemented + import org.junit.Test + import org.junit.runner.JUnitCore + + @CompileStatic + class MyTests { + @NotYetImplemented @Test void testThatFails() { + assert true + } + } + + new JUnitCore().run(MyTests) + ''') + + assert output.failureCount == 1 : '@Test method marked with @CompileStatic and @NotYetImplemented must throw an AssertionFailedError' + assert output.failures.first().exception instanceof AssertionFailedError : '@Test method marked with @CompileStatic and @NotYetImplemented must throw an AssertionFailedError' + } }