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 8406c15 GROOVY-9396: fix test for 2_5_X
8406c15 is described below
commit 8406c15c99bf0263c38641d47e20bd293410c3e5
Author: Paul King <[email protected]>
AuthorDate: Fri Feb 14 19:05:07 2020 +1000
GROOVY-9396: fix test for 2_5_X
---
.../groovy/generated/ClosureGeneratedTest.groovy | 40 ----------------------
.../transform/GeneratedAnnotationTest.groovy | 19 ++++++++++
2 files changed, 19 insertions(+), 40 deletions(-)
diff --git a/src/test/groovy/generated/ClosureGeneratedTest.groovy
b/src/test/groovy/generated/ClosureGeneratedTest.groovy
deleted file mode 100644
index 12cd70e..0000000
--- a/src/test/groovy/generated/ClosureGeneratedTest.groovy
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 groovy.generated
-
-import org.junit.Test
-
-class ClosureGeneratedTest extends AbstractGeneratedAstTestCase {
- final Class<?> classUnderTest = parseClass('''class ClassUnderTest {
- Closure<String> c(String arg) {
- def closureVar = {
- arg
- }
- closureVar
- }
- }''')
-
- @Test
- void test_captured_argument_is_annotated() {
- def objectUnderTest = classUnderTest.newInstance()
- Closure<String> cls = classUnderTest.getMethod('c', String)
- .invoke(objectUnderTest, 'var')
- assertMethodIsAnnotated(cls.class, 'getArg')
- }
-}
\ No newline at end of file
diff --git
a/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
b/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
index df02934..5f14e13 100644
--- a/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
@@ -85,4 +85,23 @@ class GeneratedAnnotationTest extends GroovyShellTestCase {
def method = person.class.declaredMethods.find { it.name ==
'invokeMethod' }
assert !('groovy.transform.Generated' in
method.annotations*.annotationType().name)
}
+
+ @Test
+ void
testCapturedArgForGeneratedClosureIsAnnotatedWithGenerated_GROOVY9396() {
+ def objectUnderTest = evaluate'''
+ class ClassUnderTest {
+ Closure<String> c(String arg) {
+ def closureVar = {
+ arg
+ }
+ closureVar
+ }
+ }
+ new ClassUnderTest()
+ '''
+
+ Closure<String> closure = objectUnderTest.class.getMethod('c',
String).invoke(objectUnderTest, 'var')
+ def getArg = closure.class.getMethod('getArg')
+ assert
getArg.annotations*.annotationType().name.contains('groovy.transform.Generated')
+ }
}
\ No newline at end of file