groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 07/08: Add testcase for Delegate
Date Fri, 28 Jun 2019 17:21:54 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 25fb07b5a8c8042f938160a12d6e12bb76d069b4
Author: aalmiray <aalmiray@gmail.com>
AuthorDate: Tue Jun 11 19:35:02 2019 +0200

    Add testcase for Delegate
---
 .../groovy/generated/DelegateGeneratedTest.groovy  | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/src/test/groovy/generated/DelegateGeneratedTest.groovy b/src/test/groovy/generated/DelegateGeneratedTest.groovy
new file mode 100644
index 0000000..eae0d0b
--- /dev/null
+++ b/src/test/groovy/generated/DelegateGeneratedTest.groovy
@@ -0,0 +1,52 @@
+package groovy.generated
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+@CompileStatic
+class DelegateGeneratedTest extends AbstractGeneratedAstTestCase {
+    final Class<?> implicitDelegate = parseClass('''
+      class ClassUnderTest {
+          static class D {
+              void m1() { }
+              void m2() { }
+          }
+          
+          @Delegate
+          D delegate = new D()
+      }''')
+
+    final Class<?> explicitDelegate = parseClass('''
+      class ClassUnderTest {
+          static class D {
+              void m1() { }
+              void m2() { }
+          }
+          
+          @Delegate
+          D delegate = new D()
+          
+          void m1() { }
+          // void m2() { }
+      }''')
+
+    @Test
+    void test_m1_is_annotated() {
+        assertMethodIsAnnotated(implicitDelegate, 'm1')
+    }
+
+    @Test
+    void test_m2_is_annotated() {
+        assertMethodIsAnnotated(implicitDelegate, 'm2')
+    }
+
+    @Test
+    void test_explicit_m1_is_not_annotated() {
+        assertMethodIsNotAnnotated(explicitDelegate, 'm1')
+    }
+
+    @Test
+    void test_explicit_m2_is_annotated() {
+        assertMethodIsAnnotated(explicitDelegate, 'm2')
+    }
+}
\ No newline at end of file


Mime
View raw message