You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2022/01/31 22:46:43 UTC

[groovy] 02/02: GROOVY-8652: add test case

This is an automated email from the ASF dual-hosted git repository.

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

commit ff8acdb406c78a2bfa1d6b11be0f67cd24160be4
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Jan 31 16:28:31 2022 -0600

    GROOVY-8652: add test case
---
 src/test/groovy/bugs/Groovy8652.groovy | 68 ++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/src/test/groovy/bugs/Groovy8652.groovy b/src/test/groovy/bugs/Groovy8652.groovy
new file mode 100644
index 0000000..487660a
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy8652.groovy
@@ -0,0 +1,68 @@
+/*
+ *  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 org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy8652 {
+
+    @Test
+    void testPutMapValue() {
+        assertScript '''
+            import groovy.transform.CompileStatic
+
+            @CompileStatic
+            class C {
+                final Map<?,?> map = [:]
+            }
+
+            @CompileStatic
+            void test() {
+                def obj = new C()
+                obj.map.put('key','value')
+                assert obj.map.key == 'value'
+            }
+
+            test()
+        '''
+    }
+
+    @Test
+    void testSetMapValue() {
+        assertScript '''
+            import groovy.transform.CompileStatic
+
+            @CompileStatic
+            class C {
+                final Map<?,?> map = [:]
+            }
+
+            @CompileStatic
+            void test() {
+                def obj = new C()
+                obj.map.key = 'value'
+                assert obj.map.key == 'value'
+            }
+
+            test()
+        '''
+    }
+}