You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/07/09 01:28:43 UTC

[groovy] branch GROOVY_3_0_X updated: minor fix-ups

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

sunlan 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 7ac8a0d  minor fix-ups
7ac8a0d is described below

commit 7ac8a0d06af99cb63ef79906bd46c300c01348e6
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Jul 4 12:41:07 2020 -0500

    minor fix-ups
    
    (cherry picked from commit acd0a6d2134d8288fa0975d88202b06f60ba39d2)
---
 src/test/groovy/bugs/Groovy8361.groovy             | 19 ++++++-----
 src/test/groovy/bugs/Groovy9607.groovy             |  4 +--
 .../transform/stc/TypeInferenceSTCTest.groovy      | 37 ++++++++++------------
 3 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy8361.groovy b/src/test/groovy/bugs/Groovy8361.groovy
index c3bee1d..35a3737 100644
--- a/src/test/groovy/bugs/Groovy8361.groovy
+++ b/src/test/groovy/bugs/Groovy8361.groovy
@@ -33,11 +33,11 @@ final class Groovy8361 {
             targetDirectory: File.createTempDir(),
             jointCompilationOptions: [memStub: true]
         )
-
         def parentDir = File.createTempDir()
-        new File(parentDir, 'p').mkdir()
-        new File(parentDir, 'q').mkdir()
         try {
+            new File(parentDir, 'p').mkdir()
+            new File(parentDir, 'q').mkdir()
+
             def a = new File(parentDir, 'p/A.java')
             a.write '''
                 package p;
@@ -65,22 +65,21 @@ final class Groovy8361 {
             }
             assert err =~ /unable to resolve class AA/
         } finally {
-            parentDir.deleteDir()
             config.targetDirectory.deleteDir()
+            parentDir.deleteDir()
         }
     }
 
     @Test
     void testAliasedImportNotUsed2() {
         def config = new CompilerConfiguration(
-            targetDirectory: File.createTempDir(),
-            jointCompilationOptions: [memStub: true]
+            targetDirectory: File.createTempDir()
         )
-
         def parentDir = File.createTempDir()
-        new File(parentDir, 'p').mkdir()
-        new File(parentDir, 'q').mkdir()
         try {
+            new File(parentDir, 'p').mkdir()
+            new File(parentDir, 'q').mkdir()
+
             def a = new File(parentDir, 'p/A.groovy')
             a.write '''
                 package p
@@ -108,8 +107,8 @@ final class Groovy8361 {
             }
             assert err =~ /unable to resolve class AA/
         } finally {
-            parentDir.deleteDir()
             config.targetDirectory.deleteDir()
+            parentDir.deleteDir()
         }
     }
 }
diff --git a/src/test/groovy/bugs/Groovy9607.groovy b/src/test/groovy/bugs/Groovy9607.groovy
index 7f10357..c19cb78 100644
--- a/src/test/groovy/bugs/Groovy9607.groovy
+++ b/src/test/groovy/bugs/Groovy9607.groovy
@@ -35,7 +35,7 @@ final class Groovy9607 {
               def name = prop.name
               help(new Runnable() {
                 void run() {
-                  assert item[name] == 'bar' // STC throws GBE if 'name' to infers as Object
+                  assert item[name] == 'bar' // STC throws GBE if 'name' infers as Object
                 }
               })
             }
@@ -54,7 +54,7 @@ final class Groovy9607 {
               name = prop.name
               help(new Runnable() {
                 void run() {
-                  assert item[name] == 'bar' // STC throws GBE if 'name' to infers as Object
+                  assert item[name] == 'bar' // STC throws GBE if 'name' infers as Object
                 }
               })
             }
diff --git a/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy
index dcee926..18fb268 100644
--- a/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/TypeInferenceSTCTest.groovy
@@ -49,35 +49,32 @@ class TypeInferenceSTCTest extends StaticTypeCheckingTestCase {
         '''
     }
 
-    void testAnnotationOnSingleMethod() {
-        GroovyShell shell = new GroovyShell()
-        shell.evaluate '''
-            // calling a method which has got some dynamic stuff in it
-
-            import groovy.transform.TypeChecked
-            import groovy.xml.MarkupBuilder
-
-            class Greeter {
-                @TypeChecked
-                String greeting(String name) {
-                    generateMarkup(name.toUpperCase())
+    void testDynamicMethodWithinTypeCheckedClass() {
+        assertScript '''
+            import groovy.transform.*
+
+            class C {
+                String m(String s) {
+                    generateMarkup(s.toUpperCase())
                 }
 
-                // MarkupBuilder is dynamic so we won't do typechecking here
-                String generateMarkup(String name) {
+                // MarkupBuilder is dynamic so skip type-checking
+                @TypeChecked(TypeCheckingMode.SKIP)
+                String generateMarkup(String s) {
                     def sw = new StringWriter()
-                    def mkp = new MarkupBuilder()
-                    mkp.html {
+                    def mb = new groovy.xml.MarkupBuilder(sw)
+                    mb.html {
                         body {
-                            div name
+                            div s
                         }
                     }
-                    sw
+                    sw.toString()
                 }
             }
 
-            def g = new Greeter()
-            g.greeting("Guillaume")
+            def c = new C()
+            def xml = c.m('x')
+            // TODO: check XML
         '''
     }