groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emil...@apache.org
Subject [groovy] branch master updated: minor refactor
Date Thu, 10 Oct 2019 17:18:39 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 6fa833b  minor refactor
6fa833b is described below

commit 6fa833b7de0910f7ddcecd18c2a2f11ecd968485
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Thu Oct 10 12:18:36 2019 -0500

    minor refactor
---
 src/test/groovy/bugs/Groovy3852.groovy    | 115 ++++++++++++++++++++++++++++++
 src/test/groovy/bugs/Groovy3852Bug.groovy | 108 ----------------------------
 2 files changed, 115 insertions(+), 108 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy3852.groovy b/src/test/groovy/bugs/Groovy3852.groovy
new file mode 100644
index 0000000..7277b5d
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy3852.groovy
@@ -0,0 +1,115 @@
+/*
+ *  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.bugs
+
+import groovy.transform.CompileStatic
+import org.junit.Assert
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.test.GroovyAssert.shouldFail
+
+@CompileStatic
+final class Groovy3852 {
+
+    @Test
+    void testDuplicationAnnotationOnClassNoParams() {
+        def err = shouldFail '''
+            @Deprecated
+            @Deprecated
+            @Deprecated
+            class A {}
+        '''
+
+        assert err =~ /Cannot specify duplicate annotation/
+    }
+
+    @Test
+    void testDuplicationAnnotationOnClassWithParams() {
+        def err = shouldFail '''
+            import java.lang.annotation.*
+            @Retention(value=RetentionPolicy.CLASS)
+            @Retention(value=RetentionPolicy.CLASS)
+            @interface B {}
+        '''
+
+        assert err =~ /Cannot specify duplicate annotation/
+    }
+
+    @Test
+    void testDuplicationAnnotationOnOtherTargets() {
+        def err = shouldFail '''
+            class C {
+                @Deprecated
+                @Deprecated
+                @Deprecated
+                def m() {}
+            }
+        '''
+
+        assert err =~ /Cannot specify duplicate annotation/
+
+        err = shouldFail '''
+            class D {
+                @Deprecated
+                @Deprecated
+                @Deprecated
+                def p
+            }
+        '''
+
+        assert err =~ /Cannot specify duplicate annotation/
+    }
+
+    @Test
+    void testDuplicationNonRuntimeRetentionPolicyAnnotations() {
+        try {
+            assertScript '''
+                @Newify(auto=false, value=String)
+                @Newify(auto=false, value=String)
+                class Groovy3930 {
+                    static void main(args) {
+                        println 'success'
+                    }
+                }
+            '''
+        } catch (any) {
+            Assert.fail('Compilation should have succeeded as it has duplication annotations
but with retention policy "not RUNTIME"')
+        }
+    }
+
+    @Test
+    void testDuplicationAnnotationsForImport() {
+        // TODO: replace with better test - Newify doesn't really make sense for import
+        try {
+            assertScript '''
+                @Newify(auto=false, value=String)
+                @Newify(auto=false, value=String)
+                import java.lang.String
+                class Groovy3925 {
+                    static void main(args) {
+                        println 'success'
+                    }
+                }
+            '''
+        } catch (any) {
+            Assert.fail('Compilation should have succeeded as it has duplication annotations
but with retention policy "not RUNTIME"')
+        }
+    }
+}
diff --git a/src/test/groovy/bugs/Groovy3852Bug.groovy b/src/test/groovy/bugs/Groovy3852Bug.groovy
deleted file mode 100644
index f7b03a6..0000000
--- a/src/test/groovy/bugs/Groovy3852Bug.groovy
+++ /dev/null
@@ -1,108 +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.bugs
-
-import gls.CompilableTestSupport
-
-class Groovy3852Bug extends CompilableTestSupport {
-    def gcl = new GroovyClassLoader()
-    void testDuplicationAnnotationOnClassNoParams() {
-        try {
-            gcl.parseClass """
-                @Deprecated
-                @Deprecated
-                @Deprecated
-                class TooDeprecatedGroovy3852V1 {}
-            """
-            fail('The class compilation should have failed as it has duplication annotations')
-        }catch(ex) {
-            assertTrue ex.message.contains('Cannot specify duplicate annotation')
-        }
-    }
-
-    void testDuplicationAnnotationOnClassWithParams() {
-        try {
-            gcl.parseClass """
-                import java.lang.annotation.*
-                @Retention(value=RetentionPolicy.CLASS)
-                @Retention(value=RetentionPolicy.CLASS)
-                @interface TooDeprecatedGroovy3852V2 {}
-            """
-            fail('The class compilation should have failed as it has duplication annotations')
-        }catch(ex) {
-            assertTrue ex.message.contains('Cannot specify duplicate annotation')
-        }
-    }
-
-    void testDuplicationAnnotationOnOtherTargets() {
-        try {
-            gcl.parseClass """
-                class TooDeprecatedGroovy3852V3 {
-                    @Deprecated
-                    @Deprecated
-                    @Deprecated
-                    def m() {}
-                }
-            """
-            fail('The class compilation should have failed as it has duplication annotations
on a method')
-        }catch(ex) {
-            assertTrue ex.message.contains('Cannot specify duplicate annotation')
-        }
-
-        try {
-            gcl.parseClass """
-                class TooDeprecatedGroovy3852V3 {
-                    @Deprecated
-                    @Deprecated
-                    @Deprecated
-                    def f
-                }
-            """
-            fail('The class compilation should have failed as it has duplication annotations
on a field')
-        }catch(ex) {
-            assertTrue ex.message.contains('Cannot specify duplicate annotation')
-        }
-    }
-
-    void testDuplicationNonRuntimeRetentionPolicyAnnotations() {
-        try {
-            gcl.parseClass """
-                @Newify(auto=false, value=String)
-                @Newify(auto=false, value=String)
-                class Groovy3930 {}
-            """
-        } catch (ex) {
-            fail('The class compilation should have succeeded as it has duplication annotations
but with retention policy not at RUNTIME')
-        }
-    }
-
-    void testDuplicationAnnotationsForImport() {
-        // TODO: replace with better test - Newify doesn't really make sense for import
-        try {
-            gcl.parseClass """
-                @Newify(auto=false, value=String)
-                @Newify(auto=false, value=String)
-                import java.lang.String
-                class Groovy3925 {}
-            """
-        } catch (ex) {
-            fail('The class compilation should have succeeded as it has duplication annotations
but with retention policy not at RUNTIME')
-        }
-    }
-}
\ No newline at end of file


Mime
View raw message