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 21:08:00 UTC

[groovy] 02/06: GROOVY-9892: 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 a45809cb38cea6e40242845fec24a09970628b6c
Author: Fiouz <fi...@gmail.com>
AuthorDate: Tue Jan 12 21:52:03 2021 +0800

    GROOVY-9892: add test case
---
 .../classgen/asm/sc/bugs/Groovy9892Bug.groovy      | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy9892Bug.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy9892Bug.groovy
new file mode 100644
index 0000000..142892a
--- /dev/null
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy9892Bug.groovy
@@ -0,0 +1,42 @@
+/*
+ *  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.classgen.asm.sc.bugs
+
+import groovy.transform.stc.StaticTypeCheckingTestCase
+import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
+
+final class Groovy9892Bug extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
+    void testUnaryIncrementInGString() {
+        assertScript '''
+            class C {
+                int i, j
+
+                def call() {
+                    { ->
+                        "Hello${++i}World${j++}"
+                    }.call()
+                }
+            }
+            def obj = new C()
+            assert obj.call() == 'Hello1World0'
+            assert obj.i == 1
+            assert obj.j == 1
+        '''
+    }
+}