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 2023/07/20 13:29:38 UTC
[groovy] branch GROOVY_3_0_X updated: GROOVY-11126: add test case
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new c996d10d24 GROOVY-11126: add test case
c996d10d24 is described below
commit c996d10d24d2e69293aa8dbc52152c7f28db5ce8
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jul 20 07:38:12 2023 -0500
GROOVY-11126: add test case
---
src/test/groovy/bugs/Groovy11126.groovy | 57 +++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/src/test/groovy/bugs/Groovy11126.groovy b/src/test/groovy/bugs/Groovy11126.groovy
new file mode 100644
index 0000000000..36785caca0
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy11126.groovy
@@ -0,0 +1,57 @@
+/*
+ * 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.codehaus.groovy.control.CompilerConfiguration
+import org.junit.Test
+
+final class Groovy11126 {
+
+ @Test
+ void testSafeCall() {
+ def config = new CompilerConfiguration()
+ config.optimizationOptions.indy = true
+ new GroovyShell(config).evaluate '''
+ def test(String string) {
+ string?.size()
+ }
+ 10000.times {
+ test('1')
+ test('')
+ }
+ test()
+ '''
+ }
+
+ @Test
+ void testSafeName() {
+ def config = new CompilerConfiguration()
+ config.optimizationOptions.indy = true
+ new GroovyShell(config).evaluate '''
+ def test(String string) {
+ string?.chars
+ }
+ 10000.times {
+ test('1')
+ test('')
+ }
+ test()
+ '''
+ }
+}