groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch master updated: GROOVY-9043: additional test cases
Date Mon, 06 May 2019 12:30:25 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk 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 03c6f59  GROOVY-9043: additional test cases
03c6f59 is described below

commit 03c6f59beaed61b4c460b73491072b7db6806cdb
Author: Paul King <paulk@asert.com.au>
AuthorDate: Mon May 6 22:28:18 2019 +1000

    GROOVY-9043: additional test cases
---
 .../packageScope/DifferentPackageTest.groovy       | 89 ++++++++++++++++++++++
 .../groovy/transform/packageScope/p/One.groovy     | 24 ++++++
 2 files changed, 113 insertions(+)

diff --git a/src/test/org/codehaus/groovy/transform/packageScope/DifferentPackageTest.groovy
b/src/test/org/codehaus/groovy/transform/packageScope/DifferentPackageTest.groovy
new file mode 100644
index 0000000..b41b9c6
--- /dev/null
+++ b/src/test/org/codehaus/groovy/transform/packageScope/DifferentPackageTest.groovy
@@ -0,0 +1,89 @@
+/*
+ *  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.transform.packageScope
+
+import org.codehaus.groovy.control.MultipleCompilationErrorsException
+
+class DifferentPackageTest extends GroovyTestCase {
+    void _FIXME_testSamePackageShouldSeeInstanceProps() {
+        assertScript '''
+            package org.codehaus.groovy.transform.packageScope.p
+
+            @groovy.transform.CompileStatic
+            class Two extends One {
+                void valSize() {
+                    value.size()
+                }
+            }
+
+            assert new Two().valSize() == 3
+        '''
+    }
+
+    void _FIXME_testSamePackageShouldSeeStaticProps() {
+        assertScript '''
+            package org.codehaus.groovy.transform.packageScope.p
+
+            @groovy.transform.CompileStatic
+            class Three {
+                static void halfNum() {
+                    One.NUM / 2
+                }
+            }
+
+            assert Three.halfNum() == 21
+        '''
+    }
+
+    void _FIXME_testDifferentPackageShouldNotSeeInstanceProps() {
+        def message = shouldFail(MultipleCompilationErrorsException, '''
+            package org.codehaus.groovy.transform.packageScope.q
+
+            import org.codehaus.groovy.transform.packageScope.p.One
+
+            @groovy.transform.CompileStatic
+            class Two extends One {
+                void valSize() {
+                    value.size()
+                }
+            }
+
+            assert new Two().valSize() == 3
+        ''')
+        assert message.matches('(?s).*Access to .*value is forbidden.*')
+    }
+
+    void testDifferentPackageShouldNotSeeStaticProps() {
+        def message = shouldFail(MultipleCompilationErrorsException, '''
+            package org.codehaus.groovy.transform.packageScope.q
+
+            import org.codehaus.groovy.transform.packageScope.p.One
+
+            @groovy.transform.CompileStatic
+            class Three {
+                static void halfNum() {
+                    One.NUM / 2
+                }
+            }
+
+            assert Three.halfNum() == 21
+        ''')
+        assert message.matches('(?s).*Access to .*One#NUM is forbidden.*')
+    }
+}
diff --git a/src/test/org/codehaus/groovy/transform/packageScope/p/One.groovy b/src/test/org/codehaus/groovy/transform/packageScope/p/One.groovy
new file mode 100644
index 0000000..f4fc0e6
--- /dev/null
+++ b/src/test/org/codehaus/groovy/transform/packageScope/p/One.groovy
@@ -0,0 +1,24 @@
+/*
+ *  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.transform.packageScope.p
+
+class One {
+    @groovy.transform.PackageScope final String value = 'val'
+    @groovy.transform.PackageScope final static Integer NUM = 42
+}


Mime
View raw message