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 2019/08/13 13:32:36 UTC

[groovy] branch master updated (d321754 -> 3fbccfb)

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

sunlan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from d321754  GROOVY-9031: correct trait property generics before writing stub methods
     new bd9a6e8  Add script filters for test support files
     new 088888c  Added missing package statements (or qualifiers)
     new 4bca463  Moved some type declarations inside test class to hide them
     new 3fbccfb  Import public method instead of private field

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gradle/eclipse.gradle                              |    2 +
 src/test/{groovy => }/NoPackageTest.groovy         |    4 +-
 .../createLoop.groovy => ScriptAsUnitTest.groovy}  |   10 +-
 src/test/gls/annotations/AnnotationTest.groovy     |    4 +-
 src/test/gls/annotations/Base3278.groovy           |    2 +
 src/test/gls/annotations/Child2.groovy             |    2 +
 src/test/gls/annotations/ConstAnnotation.groovy    |    2 +
 .../gls/invocation/ClassDuplicationTest.groovy     |    6 +-
 src/test/groovy/BinaryStreamsTest.groovy           |    4 +-
 src/test/groovy/StaticImportTest.groovy            |   10 +-
 src/test/groovy/ThisAndSuperTest.groovy            |    9 +-
 src/test/groovy/UnitTestAsScriptTest.groovy        |   22 -
 src/test/groovy/benchmarks/createLoop.groovy       |    5 +-
 src/test/groovy/benchmarks/loop.groovy             |    3 +-
 src/test/groovy/benchmarks/loop2.groovy            |    2 -
 src/test/groovy/bugs/GROOVY3934Helper.groovy       |   19 -
 .../bugs/{Groovy1567_Bug.java => Groovy1567.java}  |   21 +-
 .../bugs/{Groovy5318.groovy => Groovy1759.groovy}  |   36 +-
 src/test/groovy/bugs/Groovy1759_Bug.groovy         |   39 -
 .../{Groovy2951Bug.groovy => Groovy2951.groovy}    |   16 +-
 .../{Groovy3719Bug.groovy => Groovy3719.groovy}    |   21 +-
 src/test/groovy/bugs/Groovy3719Bug_script.groovy   |   20 -
 .../{Groovy596_Bug.groovy => Groovy596.groovy}     |   60 +-
 .../{Groovy7620Bug.groovy => Groovy7620.groovy}    |   24 +-
 ...67_script.groovy => scriptForGroovy1567.groovy} |    1 -
 .../scriptForGroovy3934.groovy}                    |    3 +-
 .../{Groovy3406Test.groovy => Groovy3406.groovy}   |   14 +-
 src/test/groovy/lang/GroovyShellTest.java          |    2 +-
 src/test/groovy/lang/MapOfClosureTest.groovy       |   35 +-
 .../groovy/lang/gcldeadlock/DeadlockBugUtil.groovy |    4 +-
 src/test/groovy/lang/gcldeadlock/script1.groovy    |    2 +-
 src/test/groovy/script/ScriptTest.groovy           |   19 +-
 src/test/groovy/script/ScriptWithFunctions.groovy  |   29 -
 .../script/{ShowArgs.groovy => scriptArgs.groovy}  |    0
 .../{HelloWorld.groovy => scriptHelloWorld.groovy} |    0
 ...HelloWorld2.groovy => scriptHelloWorld2.groovy} |    0
 ...Script.groovy => scriptMethodReflection.groovy} |    0
 ...Script.groovy => scriptThatCallsAnother.groovy} |    2 +-
 ...assWithScript.groovy => scriptWithClass.groovy} |    0
 ...ureInScript.groovy => scriptWithClosure.groovy} |    0
 .../{EvalInScript.groovy => scriptWithEval.groovy} |    2 +-
 ...pt.groovy => scriptWithPackageStatement.groovy} |    0
 src/test/indy/IndyUsageTest.groovy                 |   34 +-
 .../groovy/ast/LazyInitOnClassNodeTest.groovy      |   11 +-
 .../groovy/classgen/ReflectorGeneratorTest.java    |   10 +-
 .../org/codehaus/groovy/classgen/RunBugsTest.java  |    2 +-
 .../groovy/runtime/memoize/NullValueTest.groovy    |   23 +-
 .../traitx/TraitASTTransformationTest.groovy       | 2065 +++++++++++---------
 .../util/AbstractConcurrentMapSegmentTest.groovy   |    8 +-
 49 files changed, 1352 insertions(+), 1257 deletions(-)
 rename src/test/{groovy => }/NoPackageTest.groovy (93%)
 copy src/test/{groovy/benchmarks/createLoop.groovy => ScriptAsUnitTest.groovy} (91%)
 delete mode 100644 src/test/groovy/UnitTestAsScriptTest.groovy
 delete mode 100644 src/test/groovy/bugs/GROOVY3934Helper.groovy
 rename src/test/groovy/bugs/{Groovy1567_Bug.java => Groovy1567.java} (73%)
 copy src/test/groovy/bugs/{Groovy5318.groovy => Groovy1759.groovy} (59%)
 delete mode 100644 src/test/groovy/bugs/Groovy1759_Bug.groovy
 rename src/test/groovy/bugs/{Groovy2951Bug.groovy => Groovy2951.groovy} (84%)
 rename src/test/groovy/bugs/{Groovy3719Bug.groovy => Groovy3719.groovy} (73%)
 delete mode 100644 src/test/groovy/bugs/Groovy3719Bug_script.groovy
 rename src/test/groovy/bugs/{Groovy596_Bug.groovy => Groovy596.groovy} (51%)
 rename src/test/groovy/bugs/{Groovy7620Bug.groovy => Groovy7620.groovy} (76%)
 rename src/test/groovy/bugs/{bug1567_script.groovy => scriptForGroovy1567.groovy} (97%)
 copy src/test/groovy/{script/HelloWorld.groovy => bugs/scriptForGroovy3934.groovy} (95%)
 rename src/test/groovy/lang/{Groovy3406Test.groovy => Groovy3406.groovy} (90%)
 delete mode 100644 src/test/groovy/script/ScriptWithFunctions.groovy
 rename src/test/groovy/script/{ShowArgs.groovy => scriptArgs.groovy} (100%)
 rename src/test/groovy/script/{HelloWorld.groovy => scriptHelloWorld.groovy} (100%)
 rename src/test/groovy/script/{HelloWorld2.groovy => scriptHelloWorld2.groovy} (100%)
 rename src/test/groovy/script/{MethodTestScript.groovy => scriptMethodReflection.groovy} (100%)
 rename src/test/groovy/script/{CallAnotherScript.groovy => scriptThatCallsAnother.groovy} (92%)
 rename src/test/groovy/script/{ClassWithScript.groovy => scriptWithClass.groovy} (100%)
 rename src/test/groovy/script/{UseClosureInScript.groovy => scriptWithClosure.groovy} (100%)
 rename src/test/groovy/script/{EvalInScript.groovy => scriptWithEval.groovy} (93%)
 rename src/test/groovy/script/{PackageScript.groovy => scriptWithPackageStatement.groovy} (100%)


[groovy] 04/04: Import public method instead of private field

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3fbccfbe0b22a2c718c9b1a325ccce26f3b473f0
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Aug 12 11:41:36 2019 -0500

    Import public method instead of private field
---
 src/test/groovy/StaticImportTest.groovy | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/test/groovy/StaticImportTest.groovy b/src/test/groovy/StaticImportTest.groovy
index 5f12f0b..4ef9adc 100644
--- a/src/test/groovy/StaticImportTest.groovy
+++ b/src/test/groovy/StaticImportTest.groovy
@@ -27,7 +27,7 @@ import static junit.framework.Assert.format
 import static junit.framework.Assert.assertEquals
 import static groovy.StaticImportTarget.x
 import static groovy.StaticImportTarget.z // do not remove
-import static groovy.StaticImportTarget.cl
+import static groovy.StaticImportTarget.getCl
 import static java.lang.Math.*
 import static java.util.Calendar.getInstance as now
 import static groovy.API.*
@@ -257,12 +257,14 @@ class StaticImportTest extends CompilableTestSupport {
             fail()
         } catch (MissingMethodException expected) {}
     }
-    
-    void testStaticImportOfAClosureField() { //GROOVY-3945
+
+    // GROOVY-3945
+    void testStaticImportOfAClosureProperty() {
         assert cl() == 'StaticImportTarget#static closure called'
     }
 
-    void testStaticPropertyImportedImplementedAsGetter() { //GROOVY-4145
+    // GROOVY-4145
+    void testStaticPropertyImportedImplementedAsGetter() {
         assert foo4145 == 3
     }
 


[groovy] 01/04: Add script filters for test support files

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bd9a6e8cacacabd705db9d09e666654694e41faf
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Aug 12 11:01:24 2019 -0500

    Add script filters for test support files
---
 gradle/eclipse.gradle                              |  2 ++
 .../HelloWorld.groovy => ScriptAsUnitTest.groovy}  |  6 +++--
 src/test/groovy/UnitTestAsScriptTest.groovy        | 22 ----------------
 .../bugs/{Groovy1567_Bug.java => Groovy1567.java}  | 21 ++++++++--------
 .../{Groovy3719Bug.groovy => Groovy3719.groovy}    | 21 ++++++++++------
 src/test/groovy/bugs/Groovy3719Bug_script.groovy   | 20 ---------------
 ...67_script.groovy => scriptForGroovy1567.groovy} |  1 -
 ...934Helper.groovy => scriptForGroovy3934.groovy} |  3 ++-
 src/test/groovy/lang/GroovyShellTest.java          |  2 +-
 src/test/groovy/script/ScriptTest.groovy           | 19 ++++++--------
 src/test/groovy/script/ScriptWithFunctions.groovy  | 29 ----------------------
 .../script/{ShowArgs.groovy => scriptArgs.groovy}  |  0
 .../{HelloWorld.groovy => scriptHelloWorld.groovy} |  0
 ...HelloWorld2.groovy => scriptHelloWorld2.groovy} |  0
 ...Script.groovy => scriptMethodReflection.groovy} |  0
 ...Script.groovy => scriptThatCallsAnother.groovy} |  2 +-
 ...assWithScript.groovy => scriptWithClass.groovy} |  0
 ...ureInScript.groovy => scriptWithClosure.groovy} |  0
 .../{EvalInScript.groovy => scriptWithEval.groovy} |  2 +-
 ...pt.groovy => scriptWithPackageStatement.groovy} |  0
 .../org/codehaus/groovy/classgen/RunBugsTest.java  |  2 +-
 21 files changed, 43 insertions(+), 109 deletions(-)

diff --git a/gradle/eclipse.gradle b/gradle/eclipse.gradle
index 207142e..2372bc4 100644
--- a/gradle/eclipse.gradle
+++ b/gradle/eclipse.gradle
@@ -59,6 +59,8 @@ allprojects {
                 append('''\
                     eclipse.preferences.version=1
                     groovy.compiler.level=30
+                    groovy.script.filters=**/*.gradle,n,**/script*.groovy,y,**/*resources/**/*.groovy,y,**/benchmarks/**/*.groovy,y
+                    org.codehaus.groovy.eclipse.preferences.compiler.project=true
                     '''.stripIndent()
                 )
             }
diff --git a/src/test/groovy/script/HelloWorld.groovy b/src/test/ScriptAsUnitTest.groovy
similarity index 91%
copy from src/test/groovy/script/HelloWorld.groovy
copy to src/test/ScriptAsUnitTest.groovy
index 8764681..f8ec0a0 100644
--- a/src/test/groovy/script/HelloWorld.groovy
+++ b/src/test/ScriptAsUnitTest.groovy
@@ -16,6 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-println "Hello world"
-
 
+x = 123
+x *= 2
+println "Running unit test with a = ${x}"
+assert x == 246
diff --git a/src/test/groovy/UnitTestAsScriptTest.groovy b/src/test/groovy/UnitTestAsScriptTest.groovy
deleted file mode 100644
index da8b751..0000000
--- a/src/test/groovy/UnitTestAsScriptTest.groovy
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  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.
- */
-a = 123
-a *= 2
-println "Running unit test with a = ${a}"
-assert a == 246
diff --git a/src/test/groovy/bugs/Groovy1567_Bug.java b/src/test/groovy/bugs/Groovy1567.java
similarity index 73%
rename from src/test/groovy/bugs/Groovy1567_Bug.java
rename to src/test/groovy/bugs/Groovy1567.java
index bb54183..cac78fc 100644
--- a/src/test/groovy/bugs/Groovy1567_Bug.java
+++ b/src/test/groovy/bugs/Groovy1567.java
@@ -21,30 +21,29 @@ package groovy.bugs;
 import groovy.lang.Binding;
 import groovy.lang.GroovyShell;
 import groovy.util.GroovyScriptEngine;
-import groovy.util.ResourceException;
-import groovy.util.ScriptException;
+import org.junit.Test;
 
 import java.io.File;
-import java.io.IOException;
 
-import junit.framework.TestCase;
+public final class Groovy1567 {
 
-public class Groovy1567_Bug extends TestCase {
-    public void testGroovyScriptEngineVsGroovyShell() throws IOException, ResourceException, ScriptException {
+    @Test
+    public void testGroovyScriptEngineVsGroovyShell() throws Exception {
         // @todo refactor this path
-        File currentDir = new File("./src/test/groovy/bugs");
-        String file = "bug1567_script.groovy";
+        File currentDir = new File("src/test/groovy/bugs");
+        String file = "scriptForGroovy1567.groovy";
 
         Binding binding = new Binding();
         GroovyShell shell = new GroovyShell(binding);
         String[] test = null;
-        Object result = shell.run(new File(currentDir, file), test);
+
+        //
+        shell.run(new File(currentDir, file), test);
 
         String[] roots = new String[]{currentDir.getAbsolutePath()};
         GroovyScriptEngine gse = new GroovyScriptEngine(roots);
         binding = new Binding();
-        // a MME was ensued here stating no 't.start()' was available
-        // in the script
+        // a MME was ensued here stating no 't.start()' was available in the script
         gse.run(file, binding);
     }
 }
diff --git a/src/test/groovy/bugs/Groovy3719Bug.groovy b/src/test/groovy/bugs/Groovy3719.groovy
similarity index 73%
rename from src/test/groovy/bugs/Groovy3719Bug.groovy
rename to src/test/groovy/bugs/Groovy3719.groovy
index 190c312..e7c55db 100644
--- a/src/test/groovy/bugs/Groovy3719Bug.groovy
+++ b/src/test/groovy/bugs/Groovy3719.groovy
@@ -18,14 +18,19 @@
  */
 package groovy.bugs
 
-class Groovy3719Bug extends GroovyTestCase {
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.shouldFail
+
+final class Groovy3719 {
+
+    @Test
     void testScriptThrowingNoSuchMethodException() {
-        try {
-            GroovyShell shell = new GroovyShell();
-            String[] args = new String[0];
-            shell.run(new File("src/test/groovy/bugs/Groovy3719Bug_script.groovy"), args);
-        } catch(ex) {
-            assert ex instanceof NoSuchMethodException
-        }
+        def err = shouldFail '''
+            println "YES I CAN!"
+            throw new NoSuchMethodException()
+        '''
+
+        assert err instanceof NoSuchMethodException
     }
 }
diff --git a/src/test/groovy/bugs/Groovy3719Bug_script.groovy b/src/test/groovy/bugs/Groovy3719Bug_script.groovy
deleted file mode 100644
index d9b883d..0000000
--- a/src/test/groovy/bugs/Groovy3719Bug_script.groovy
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- *  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.
- */
-println "YES I CAN!"
-throw new NoSuchMethodException()
\ No newline at end of file
diff --git a/src/test/groovy/bugs/bug1567_script.groovy b/src/test/groovy/bugs/scriptForGroovy1567.groovy
similarity index 97%
rename from src/test/groovy/bugs/bug1567_script.groovy
rename to src/test/groovy/bugs/scriptForGroovy1567.groovy
index 8a0a68a..be594bc 100644
--- a/src/test/groovy/bugs/bug1567_script.groovy
+++ b/src/test/groovy/bugs/scriptForGroovy1567.groovy
@@ -16,7 +16,6 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package groovy.bugs
 
 t = new Thread({ println "Groovy" })
 t.start()
diff --git a/src/test/groovy/bugs/GROOVY3934Helper.groovy b/src/test/groovy/bugs/scriptForGroovy3934.groovy
similarity index 95%
rename from src/test/groovy/bugs/GROOVY3934Helper.groovy
rename to src/test/groovy/bugs/scriptForGroovy3934.groovy
index 10a3b36..9ac9b3f 100644
--- a/src/test/groovy/bugs/GROOVY3934Helper.groovy
+++ b/src/test/groovy/bugs/scriptForGroovy3934.groovy
@@ -16,4 +16,5 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-return 'GROOVY3934Helper script called'
\ No newline at end of file
+
+return 'GROOVY3934Helper script called'
diff --git a/src/test/groovy/lang/GroovyShellTest.java b/src/test/groovy/lang/GroovyShellTest.java
index 15c8964..d254a74 100644
--- a/src/test/groovy/lang/GroovyShellTest.java
+++ b/src/test/groovy/lang/GroovyShellTest.java
@@ -119,7 +119,7 @@ public class GroovyShellTest extends GroovyTestCase {
     }
 
     public void testWithGCSWithURL() throws Exception {
-        String scriptFileName = "src/test/groovy/bugs/GROOVY3934Helper.groovy";
+        String scriptFileName = "src/test/groovy/bugs/scriptForGroovy3934.groovy";
         File helperScript = new File(scriptFileName);
         if(!helperScript.exists()) {
             fail("File " + scriptFileName + " does not exist");
diff --git a/src/test/groovy/script/ScriptTest.groovy b/src/test/groovy/script/ScriptTest.groovy
index 9098b17..3adccca 100644
--- a/src/test/groovy/script/ScriptTest.groovy
+++ b/src/test/groovy/script/ScriptTest.groovy
@@ -18,18 +18,15 @@
  */
 package groovy.script
 
-class ScriptTest extends GroovyTestCase {
+import groovy.test.GroovyTestCase
+
+final class ScriptTes extends GroovyTestCase {
+
     void testScripts() {
-        def file = new File("src/test/groovy/script")
-        file.eachFile {
+        new File('src/test/groovy/script').eachFile {
             def name = it.name
-            if (name.endsWith('.groovy')) {
-                if (name.startsWith('ScriptTest')) {
-                    //
-                }
-                else {
-                    runScript(it)
-                }
+            if (name.startsWith('script') && name.endsWith('.groovy')) {
+                runScript(it)
             }
         }
     }
@@ -47,4 +44,4 @@ class ScriptTest extends GroovyTestCase {
             println("Caught: " + e)
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/groovy/script/ScriptWithFunctions.groovy b/src/test/groovy/script/ScriptWithFunctions.groovy
deleted file mode 100644
index 3db157d..0000000
--- a/src/test/groovy/script/ScriptWithFunctions.groovy
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  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.
- */
-def foo(list, value) {
-    println "Calling function foo() with param ${value}"
-    list << value
-}
-
-x = []
-foo(x, 1)
-foo(x, 2)
-assert x == [1, 2]
-
-println "Creating list ${x}"
\ No newline at end of file
diff --git a/src/test/groovy/script/ShowArgs.groovy b/src/test/groovy/script/scriptArgs.groovy
similarity index 100%
rename from src/test/groovy/script/ShowArgs.groovy
rename to src/test/groovy/script/scriptArgs.groovy
diff --git a/src/test/groovy/script/HelloWorld.groovy b/src/test/groovy/script/scriptHelloWorld.groovy
similarity index 100%
rename from src/test/groovy/script/HelloWorld.groovy
rename to src/test/groovy/script/scriptHelloWorld.groovy
diff --git a/src/test/groovy/script/HelloWorld2.groovy b/src/test/groovy/script/scriptHelloWorld2.groovy
similarity index 100%
rename from src/test/groovy/script/HelloWorld2.groovy
rename to src/test/groovy/script/scriptHelloWorld2.groovy
diff --git a/src/test/groovy/script/MethodTestScript.groovy b/src/test/groovy/script/scriptMethodReflection.groovy
similarity index 100%
rename from src/test/groovy/script/MethodTestScript.groovy
rename to src/test/groovy/script/scriptMethodReflection.groovy
diff --git a/src/test/groovy/script/CallAnotherScript.groovy b/src/test/groovy/script/scriptThatCallsAnother.groovy
similarity index 92%
rename from src/test/groovy/script/CallAnotherScript.groovy
rename to src/test/groovy/script/scriptThatCallsAnother.groovy
index 888cda1..26acc7e 100644
--- a/src/test/groovy/script/CallAnotherScript.groovy
+++ b/src/test/groovy/script/scriptThatCallsAnother.groovy
@@ -19,6 +19,6 @@
 println("About to call another script")
 
 script = new GroovyShell()
-script.run(new File("src/test/groovy/script/HelloWorld.groovy"), [])
+script.run(new File("src/test/groovy/script/scriptHelloWorld.groovy"), [])
 
 println("Done")
diff --git a/src/test/groovy/script/ClassWithScript.groovy b/src/test/groovy/script/scriptWithClass.groovy
similarity index 100%
rename from src/test/groovy/script/ClassWithScript.groovy
rename to src/test/groovy/script/scriptWithClass.groovy
diff --git a/src/test/groovy/script/UseClosureInScript.groovy b/src/test/groovy/script/scriptWithClosure.groovy
similarity index 100%
rename from src/test/groovy/script/UseClosureInScript.groovy
rename to src/test/groovy/script/scriptWithClosure.groovy
diff --git a/src/test/groovy/script/EvalInScript.groovy b/src/test/groovy/script/scriptWithEval.groovy
similarity index 93%
rename from src/test/groovy/script/EvalInScript.groovy
rename to src/test/groovy/script/scriptWithEval.groovy
index 28dbc5e..f95b417 100644
--- a/src/test/groovy/script/EvalInScript.groovy
+++ b/src/test/groovy/script/scriptWithEval.groovy
@@ -25,6 +25,6 @@ println("Done and now set a to ${a}")
 
 println("About to call another script")
 
-evaluate(new File("src/test/groovy/script/HelloWorld.groovy"))
+evaluate(new File("src/test/groovy/script/scriptHelloWorld.groovy"))
 
 println("Done")
diff --git a/src/test/groovy/script/PackageScript.groovy b/src/test/groovy/script/scriptWithPackageStatement.groovy
similarity index 100%
rename from src/test/groovy/script/PackageScript.groovy
rename to src/test/groovy/script/scriptWithPackageStatement.groovy
diff --git a/src/test/org/codehaus/groovy/classgen/RunBugsTest.java b/src/test/org/codehaus/groovy/classgen/RunBugsTest.java
index 4e081c9..6edaf85 100644
--- a/src/test/org/codehaus/groovy/classgen/RunBugsTest.java
+++ b/src/test/org/codehaus/groovy/classgen/RunBugsTest.java
@@ -53,7 +53,7 @@ public class RunBugsTest extends TestSupport {
     }
 
     public void testUseClosureInScript() throws Exception {
-        GroovyObject object = compile("src/test/groovy/script/UseClosureInScript.groovy");
+        GroovyObject object = compile("src/test/groovy/script/scriptWithClosure.groovy");
         object.invokeMethod("run", null);
     }
 


[groovy] 03/04: Moved some type declarations inside test class to hide them

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4bca463ce6254df7025d04741997b290b5f21ffc
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Aug 12 11:17:11 2019 -0500

    Moved some type declarations inside test class to hide them
---
 src/test/groovy/ThisAndSuperTest.groovy            |    9 +-
 .../{Groovy596_Bug.groovy => Groovy596.groovy}     |   60 +-
 .../{Groovy7620Bug.groovy => Groovy7620.groovy}    |   24 +-
 src/test/groovy/lang/MapOfClosureTest.groovy       |   35 +-
 .../groovy/classgen/ReflectorGeneratorTest.java    |   10 +-
 .../traitx/TraitASTTransformationTest.groovy       | 2065 +++++++++++---------
 6 files changed, 1183 insertions(+), 1020 deletions(-)

diff --git a/src/test/groovy/ThisAndSuperTest.groovy b/src/test/groovy/ThisAndSuperTest.groovy
index c71e895..8a865a0 100644
--- a/src/test/groovy/ThisAndSuperTest.groovy
+++ b/src/test/groovy/ThisAndSuperTest.groovy
@@ -123,15 +123,14 @@ class ThisAndSuperTest extends GroovyTestCase {
             new TestForSuperHelper6().theMethod()
         }
     }
-}
 
-class A {
-    static {
-        A.metaClass.static.empty << {-> '123' }
+    static class A {
+        static {
+            A.metaClass.static.empty << {-> '123' }
+        }
     }
 }
 
-
 class TestForSuperEach {
     def res = []
 
diff --git a/src/test/groovy/bugs/Groovy596_Bug.groovy b/src/test/groovy/bugs/Groovy596.groovy
similarity index 51%
rename from src/test/groovy/bugs/Groovy596_Bug.groovy
rename to src/test/groovy/bugs/Groovy596.groovy
index 434bb0f..d6b3c5d 100644
--- a/src/test/groovy/bugs/Groovy596_Bug.groovy
+++ b/src/test/groovy/bugs/Groovy596.groovy
@@ -18,39 +18,61 @@
  */
 package groovy.bugs
 
+import org.junit.Test
+
 import java.beans.*
 
 /**
  *  BeanInfo class usage
  */
+final class Groovy596 {
 
-class Groovy596_Bug extends GroovyTestCase {
-
+    @Test
     void testMetaClassUsageOfBeanInfoDoesNotConflictWithScriptUsageLeadingToStackOverflow() {
-        assertNotNull(new A());
-        assertNotNull(new B());
-        assertNotNull(new C());
-        assertNotNull(new D());
+        new A()
+        new B()
+        new C()
+        new D()
     }
-}
 
-class A extends java.beans.SimpleBeanInfo {}
-class B extends A {}
-class C implements java.beans.BeanInfo {
-    public BeanDescriptor getBeanDescriptor() {return null;}
+    static class A extends SimpleBeanInfo {}
+
+    static class B extends A {}
 
-    public EventSetDescriptor[] getEventSetDescriptors() {return new EventSetDescriptor[0];}
+    static class C implements BeanInfo {
 
-    public int getDefaultEventIndex() {return 0;}
+        BeanDescriptor getBeanDescriptor() {
+            null
+        }
 
-    public PropertyDescriptor[] getPropertyDescriptors() {return new PropertyDescriptor[0];}
+        EventSetDescriptor[] getEventSetDescriptors() {
+            new EventSetDescriptor[0]
+        }
 
-    public int getDefaultPropertyIndex() {return 0;}
+        int getDefaultEventIndex() {
+            0
+        }
 
-    public MethodDescriptor[] getMethodDescriptors() {return new MethodDescriptor[0];}
+        PropertyDescriptor[] getPropertyDescriptors() {
+            new PropertyDescriptor[0]
+        }
 
-    public BeanInfo[] getAdditionalBeanInfo() {return new BeanInfo[0];}
+        int getDefaultPropertyIndex() {
+            0
+        }
+
+        MethodDescriptor[] getMethodDescriptors() {
+            new MethodDescriptor[0]
+        }
+
+        BeanInfo[] getAdditionalBeanInfo() {
+            new BeanInfo[0]
+        }
+
+        java.awt.Image getIcon(int iconKind) {
+            null
+        }
+    }
 
-    public java.awt.Image getIcon(int iconKind) {return null;}
+    static class D extends C {}
 }
-class D extends C {}
diff --git a/src/test/groovy/bugs/Groovy7620Bug.groovy b/src/test/groovy/bugs/Groovy7620.groovy
similarity index 76%
rename from src/test/groovy/bugs/Groovy7620Bug.groovy
rename to src/test/groovy/bugs/Groovy7620.groovy
index 34f8789..507429f 100644
--- a/src/test/groovy/bugs/Groovy7620Bug.groovy
+++ b/src/test/groovy/bugs/Groovy7620.groovy
@@ -18,12 +18,17 @@
  */
 package groovy.bugs
 
-class Groovy7620Bug extends GroovyTestCase {
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.shouldFail
+
+final class Groovy7620 {
+
+    @Test
     void testShouldSeeThatMethodIsNotImplemented() {
-        def msg = shouldFail '''
+        def err = shouldFail '''
             abstract class A {
                abstract Object getFoo()
-
                void test() {
                    println getFoo()
                }
@@ -34,13 +39,14 @@ class Groovy7620Bug extends GroovyTestCase {
             }
 
             new B().test()
-            '''
+        '''
 
-        assert msg.contains("The method 'java.lang.Object getFoo()' is already defined in class 'B'")
+        assert err =~ /The method 'java.lang.Object getFoo\(\)' is already defined in class 'B'/
     }
 
+    @Test
     void testShouldSeeConflictInTypeSignature() {
-        def msg = shouldFail '''
+        def err = shouldFail '''
             interface C {
                Object getFoo()
             }
@@ -49,9 +55,9 @@ class Groovy7620Bug extends GroovyTestCase {
                static Object foo
             }
 
-            new B().test()
-            '''
+            new D().test()
+        '''
 
-        assert msg.contains("The method 'java.lang.Object getFoo()' is already defined in class 'D'")
+        assert err =~ /The method 'java.lang.Object getFoo\(\)' is already defined in class 'D'/
     }
 }
diff --git a/src/test/groovy/lang/MapOfClosureTest.groovy b/src/test/groovy/lang/MapOfClosureTest.groovy
index 653bfcb..3a1cc11 100644
--- a/src/test/groovy/lang/MapOfClosureTest.groovy
+++ b/src/test/groovy/lang/MapOfClosureTest.groovy
@@ -89,28 +89,29 @@ class MapOfClosureTest extends GroovyTestCase {
 
         assert ["map foo"] as String[] == c.foo(1, ['a', 'b'], [0.2, 0.3] as Double[])
     }
-}
 
-abstract class A {
-    protected prot() { "prot" }
+    //--------------------------------------------------------------------------
 
-    def pub() { "pub" }
+    static abstract class A {
+        protected prot() { "prot" }
 
-    abstract abstractMethod()
-}
+        def pub() { "pub" }
 
-class B extends A {
-    protected child() { "child" }
+        abstract abstractMethod()
+    }
 
-    def abstractMethod() { "abstract" }
-}
+    static class B extends A {
+        protected child() { "child" }
 
-class C {
-    String[] foo(int a, List b, Double[] c) { ["foo"] as String[] }
-}
+        def abstractMethod() { "abstract" }
+    }
 
-interface MultiMethodInterface {
-    String methodOne()
+    static class C {
+        String[] foo(int a, List b, Double[] c) { ["foo"] as String[] }
+    }
 
-    String methodTwo()
-}
\ No newline at end of file
+    interface MultiMethodInterface {
+        String methodOne()
+        String methodTwo()
+    }
+}
diff --git a/src/test/org/codehaus/groovy/classgen/ReflectorGeneratorTest.java b/src/test/org/codehaus/groovy/classgen/ReflectorGeneratorTest.java
index c3d0250..7bc8ee8 100644
--- a/src/test/org/codehaus/groovy/classgen/ReflectorGeneratorTest.java
+++ b/src/test/org/codehaus/groovy/classgen/ReflectorGeneratorTest.java
@@ -22,10 +22,6 @@ import org.codehaus.groovy.reflection.CachedMethod;
 
 import java.lang.reflect.InvocationTargetException;
 
-class A {
-    protected void protectedMethod() {}
-}
-
 class A_GroovyReflector {
     static void doIt () {
 
@@ -40,4 +36,8 @@ class A_GroovyReflector {
         } catch (InvocationTargetException e) {
         }
     }
-}
\ No newline at end of file
+
+    static class A {
+        protected void protectedMethod() {}
+    }
+}
diff --git a/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy b/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
index ca785f0..41eb4e0 100644
--- a/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
@@ -22,110 +22,116 @@ import groovy.transform.SelfType
 import org.codehaus.groovy.ast.ClassHelper
 import org.codehaus.groovy.ast.expr.ClassExpression
 import org.codehaus.groovy.ast.expr.ListExpression
+import org.junit.Test
 
-class TraitASTTransformationTest extends GroovyTestCase {
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.test.GroovyAssert.shouldFail
+
+final class TraitASTTransformationTest {
+
+    @Test
     void testTraitOverrideAnnotation() {
         assertScript '''
-        interface MyInterface {
-            String fooMethod()
-            void noMethod()
-        }
+            interface MyInterface {
+                String fooMethod()
+                void noMethod()
+            }
 
-        trait MyTrait implements MyInterface {
-            @Override String fooMethod() { "foo" }
-            @Override void noMethod() { }
-        }
+            trait MyTrait implements MyInterface {
+                @Override String fooMethod() { "foo" }
+                @Override void noMethod() { }
+            }
 
-        class Foo implements MyTrait {}
-        def foo = new Foo()
+            class Foo implements MyTrait {}
+            def foo = new Foo()
 
-        foo.noMethod()
-        assert foo.fooMethod() == "foo"
+            foo.noMethod()
+            assert foo.fooMethod() == "foo"
         '''
     }
 
+    @Test
     void testTraitWithNoMethod() {
         assertScript '''
-        trait MyTrait {}
+            trait MyTrait {}
 
-        class Foo implements MyTrait {}
-        def foo = new Foo()
-        assert foo instanceof MyTrait
+            class Foo implements MyTrait {}
+            def foo = new Foo()
+            assert foo instanceof MyTrait
         '''
     }
 
+    @Test
     void testTraitWithOneMethod() {
         assertScript '''
-        trait MyTrait {
-            int a() { 1 }
-
-        }
+            trait MyTrait {
+                int a() { 1 }
+            }
 
-        class Foo implements MyTrait {}
-        def foo = new Foo()
-        assert foo instanceof MyTrait
-        assert foo.a() == 1
+            class Foo implements MyTrait {}
+            def foo = new Foo()
+            assert foo instanceof MyTrait
+            assert foo.a() == 1
         '''
-
     }
 
+    @Test
     void testTraitWithTwoMethods() {
         assertScript '''
-        trait MyTrait {
-            int a() { 1 }
-            int b() { a() }
-        }
+            trait MyTrait {
+                int a() { 1 }
+                int b() { a() }
+            }
 
-        class Foo implements MyTrait {}
-        def foo = new Foo()
-        assert foo instanceof MyTrait
-        assert foo.a() == 1
-        assert foo.b() == 1
+            class Foo implements MyTrait {}
+            def foo = new Foo()
+            assert foo instanceof MyTrait
+            assert foo.a() == 1
+            assert foo.b() == 1
         '''
-
     }
 
+    @Test
     void testTraitWithTwoMethodsAndOneOverride() {
         assertScript '''
-        trait MyTrait {
-            int a() { 1 }
-            int b() { a() }
-        }
+            trait MyTrait {
+                int a() { 1 }
+                int b() { a() }
+            }
 
-        class Foo implements MyTrait {
-            int a() { 2 }
+            class Foo implements MyTrait {
+                int a() { 2 }
 
-        }
-        def foo = new Foo()
-        assert foo instanceof MyTrait
-        assert foo.a() == 2
-        assert foo.b() == 2
+            }
+            def foo = new Foo()
+            assert foo instanceof MyTrait
+            assert foo.a() == 2
+            assert foo.b() == 2
         '''
-
     }
 
+    @Test
     void testTraitWithTwoMethodsAndOneAbstract() {
         assertScript '''
-        trait MyTrait {
-            abstract int a()
-            int b() { a() }
-        }
+            trait MyTrait {
+                abstract int a()
+                int b() { a() }
+            }
 
-        class Foo implements MyTrait {
-            int a() { 2 }
+            class Foo implements MyTrait {
+                int a() { 2 }
+            }
 
-        }
-        def foo = new Foo()
-        assert foo instanceof MyTrait
-        assert foo.a() == 2
-        assert foo.b() == 2
+            def foo = new Foo()
+            assert foo instanceof MyTrait
+            assert foo.a() == 2
+            assert foo.b() == 2
         '''
-
     }
 
+    @Test
     void testTraitWithTwoMethodsAndOneAbstractNotImplemented() {
-        shouldFail {
-            assertScript '''
+        shouldFail '''
             abstract trait MyTrait {
                 abstract int a()
                 int b() { a() }
@@ -135,11 +141,16 @@ class TraitASTTransformationTest extends GroovyTestCase {
             }
             def foo = new Foo()
         '''
-        }
     }
 
+    static trait TestTrait {
+        int a() { 123 }
+    }
+
+    @Test
     void testWithPrecompiledTraitWithOneMethod() {
-        assertScript '''import org.codehaus.groovy.transform.traitx.TraitASTTransformationTest.TestTrait as TestTrait
+        assertScript '''
+            import org.codehaus.groovy.transform.traitx.TraitASTTransformationTest.TestTrait as TestTrait
 
             class Foo implements TestTrait {}
             def foo = new Foo()
@@ -147,9 +158,9 @@ class TraitASTTransformationTest extends GroovyTestCase {
         '''
     }
 
+    @Test
     void testTraitWithConstructor() {
-        shouldFail {
-            assertScript '''
+        shouldFail '''
             abstract trait MyTrait {
                 MyTrait() {
                     println 'woo'
@@ -160,36 +171,39 @@ class TraitASTTransformationTest extends GroovyTestCase {
             }
             def foo = new Foo()
         '''
-        }
     }
 
+    @Test
     void testTraitWithField() {
         assertScript '''
-        trait MyTrait {
-            private String message = 'Hello'
-            String getBlah() {
-                message
-            }
+            trait MyTrait {
+                private String message = 'Hello'
+                String getBlah() {
+                    message
+                }
 
-        }
-        class Foo implements MyTrait {}
-        def foo = new Foo()
-        assert foo.blah == 'Hello'
+            }
+            class Foo implements MyTrait {}
+            def foo = new Foo()
+            assert foo.blah == 'Hello'
         '''
     }
 
+    @Test
     void testTraitWithField2() {
-        assertScript '''import org.codehaus.groovy.transform.traitx.TestTrait2
-        class Foo implements TestTrait2 {
-            def cat() { "cat" }
-        }
-        def foo = new Foo()
-        assert foo.message == 'Hello'
-        assert foo.blah() == 'Hello'
-        assert foo.meow() == /Meow! I'm a cat/
+        assertScript '''
+            import org.codehaus.groovy.transform.traitx.TestTrait2
+            class Foo implements TestTrait2 {
+                def cat() { "cat" }
+            }
+            def foo = new Foo()
+            assert foo.message == 'Hello'
+            assert foo.blah() == 'Hello'
+            assert foo.meow() == /Meow! I'm a cat/
         '''
     }
 
+    @Test
     void testTraitWithSetValue() {
         assertScript '''
             import groovy.transform.Trait
@@ -211,13 +225,12 @@ class TraitASTTransformationTest extends GroovyTestCase {
             assert p.name == 'label2'
             p.setLabel3('label3')
             assert p.name == 'label3'
-
         '''
     }
 
+    @Test
     void testTraitWithProperty() {
         assertScript '''
-
             trait Named {
                 String name
             }
@@ -227,124 +240,132 @@ class TraitASTTransformationTest extends GroovyTestCase {
             def p = new Person(name:'Stromae')
 
             assert p.name == 'Stromae'
-
         '''
     }
 
+    @Test
     void testClosureExpressionInTrait() {
-        assertScript '''import groovy.transform.*
+        assertScript '''
+            import groovy.transform.*
 
-        trait GreetingObject {
-            String greeting = 'Welcome!'
-            Closure greeter() {
-                return { -> greeting }
+            trait GreetingObject {
+                String greeting = 'Welcome!'
+                Closure greeter() {
+                    return { -> greeting }
+                }
             }
-        }
-        class Hello implements GreetingObject {}
-        def hello = new Hello()
-        def greeter = hello.greeter()
-        assert greeter.thisObject.is(hello)
-        assert greeter() == 'Welcome!'
-
+            class Hello implements GreetingObject {}
+            def hello = new Hello()
+            def greeter = hello.greeter()
+            assert greeter.thisObject.is(hello)
+            assert greeter() == 'Welcome!'
         '''
     }
 
+    @Test
     void testUpdatePropertyFromSelf() {
         assertScript '''
-        trait Updater {
-            void update() {
-                config.key = 'value'
+            trait Updater {
+                void update() {
+                    config.key = 'value'
+                }
             }
-        }
-        class Foo implements Updater {
-            def config = [:]
-        }
-        def foo = new Foo()
-        foo.update()
-        assert foo.config.key == 'value'
+            class Foo implements Updater {
+                def config = [:]
+            }
+            def foo = new Foo()
+            foo.update()
+
+            assert foo.config.key == 'value'
         '''
     }
 
+    @Test
     void testPrivateFieldInTraitShouldBeRemapped() {
-        assertScript '''import groovy.transform.ASTTest
-import org.codehaus.groovy.control.CompilePhase
+        assertScript '''
+            import groovy.transform.ASTTest
+            import org.codehaus.groovy.control.CompilePhase
 
-trait Foo {
-    private int i = 0
-    int sum(int x) { x+i }
-    void setIndex(int index) { this.i = index }
-}
-@ASTTest(phase=CompilePhase.INSTRUCTION_SELECTION, value={
-    assert node.fields.any { it.name == 'Foo__i' }
-})
-class Bob implements Foo {
-}
-def b = new Bob()
-assert b.sum(1) == 1
-b.index = 5
-assert b.sum(1) == 6
-'''
+            trait Foo {
+                private int i = 0
+                int sum(int x) { x+i }
+                void setIndex(int index) { this.i = index }
+            }
+            @ASTTest(phase=CompilePhase.INSTRUCTION_SELECTION, value={
+                assert node.fields.any { it.name == 'Foo__i' }
+            })
+            class Bob implements Foo {
+            }
+            def b = new Bob()
+            assert b.sum(1) == 1
+            b.index = 5
+            assert b.sum(1) == 6
+        '''
     }
 
+    @Test
     void testStaticallyCompiledTrait() {
         assertScript '''
-import groovy.transform.CompileStatic
+            import groovy.transform.CompileStatic
 
-@CompileStatic
-trait Foo {
-   private String msg = 'foo'
-   abstract String bar()
-   public String foo() { bar()+msg }
+            @CompileStatic
+            trait Foo {
+               private String msg = 'foo'
+               abstract String bar()
+               public String foo() { bar()+msg }
 
-}
+            }
 
-@CompileStatic
-class A implements Foo { String bar() {'bar'}}
+            @CompileStatic
+            class A implements Foo { String bar() {'bar'}}
 
-assert new A().foo() == 'barfoo'
-'''
+            assert new A().foo() == 'barfoo'
+        '''
     }
 
+    @Test
     void testOverridePropertyDefinedInTrait() {
         assertScript '''
-trait Id {
-    Long id = 123L
-}
+            trait Id {
+                Long id = 123L
+            }
 
-class Foo implements Id {
-    Long id = 456L
-}
-def f = new Foo()
-assert f.id == 456L
-'''
+            class Foo implements Id {
+                Long id = 456L
+            }
+            def f = new Foo()
+            assert f.id == 456L
+        '''
     }
 
-
+    @Test
     void testOverridePropertyGetterDefinedInTrait() {
         assertScript '''
-trait Id {
-    Long id = 123L
-}
+            trait Id {
+                Long id = 123L
+            }
 
-class Foo implements Id {
-    Long getId() { 456L }
-}
-def f = new Foo()
-assert f.id == 456L
-'''
+            class Foo implements Id {
+                Long getId() { 456L }
+            }
+            def f = new Foo()
+            assert f.id == 456L
+        '''
     }
 
+    @Test
     void testSimpleTraitInheritance() {
         assertScript '''
-trait Top { String methodFromA() { 'A' } }
-trait Bottom extends Top { String methodFromB() { 'B' }}
-class Foo implements Bottom {}
-def f = new Foo()
-assert f.methodFromA() == 'A'
-assert f.methodFromB() == 'B'
-'''
+            trait Top { String methodFromA() { 'A' } }
+            trait Bottom extends Top { String methodFromB() { 'B' }}
+            class Foo implements Bottom {}
+            def f = new Foo()
+            assert f.methodFromA() == 'A'
+            assert f.methodFromB() == 'B'
+        '''
     }
 
+    @Test
     void testSimpleTraitInheritanceWithTraitOverridingMethodFromParent() {
         10.times {
             assertScript '''
@@ -357,103 +378,105 @@ assert f.methodFromB() == 'B'
                 def f = new Foo()
                 assert f.methodFromA() == 'B'
                 assert f.methodFromB() == 'B'
-                '''
+            '''
         }
     }
 
+    @Test
     void testSimpleTraitInheritanceWithTraitOverridingMethodFromParentAndClass() {
         assertScript '''
-trait Top { String methodFromA() { 'A' } }
-trait Bottom extends Top {
-    String methodFromA() { 'B' }
-    String methodFromB() { 'B' }
-}
-class Foo implements Bottom {
-    String methodFromA() { 'Foo' }
-}
-def f = new Foo()
-assert f.methodFromA() == 'Foo'
-assert f.methodFromB() == 'B'
-'''
+            trait Top { String methodFromA() { 'A' } }
+            trait Bottom extends Top {
+                String methodFromA() { 'B' }
+                String methodFromB() { 'B' }
+            }
+            class Foo implements Bottom {
+                String methodFromA() { 'Foo' }
+            }
+            def f = new Foo()
+            assert f.methodFromA() == 'Foo'
+            assert f.methodFromB() == 'B'
+        '''
     }
 
     void testTraitOnEnum() {
-        assertScript '''trait WithBar { int bar }
-
-enum MyEnum implements WithBar {
-    X, Y
-}
+        assertScript '''
+            trait WithBar { int bar }
 
-class MyClass implements WithBar {}
+            enum MyEnum implements WithBar {
+                X, Y
+            }
 
-def o = new MyClass()
-o.bar = 123
-assert o.bar == 123
+            class MyClass implements WithBar {}
 
-MyEnum.X.bar = 123
-assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
+            def o = new MyClass()
+            o.bar = 123
+            assert o.bar == 123
 
-'''
+            MyEnum.X.bar = 123
+            assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
+        '''
     }
 
+    @Test
     void testClassImplementingTraitWithSameMethod() {
         10.times {
             assertScript '''
-            trait A {
-                int foo() { 1 }
-            }
-            trait B {
-                int foo() { 2 }
-            }
-            class AB implements A,B {
-            }
-            def x = new AB()
-            assert x.foo() == 2 // default order, B is first
+                trait A {
+                    int foo() { 1 }
+                }
+                trait B {
+                    int foo() { 2 }
+                }
+                class AB implements A,B {
+                }
+                def x = new AB()
+                assert x.foo() == 2 // default order, B is first
             '''
 
             assertScript '''
-            trait A {
-                int foo() { 1 }
-            }
-            trait B {
-                int foo() { 2 }
-            }
-            class AB implements B,A {
-            }
-            def x = new AB()
-            assert x.foo() == 1 // default order, A is first
+                trait A {
+                    int foo() { 1 }
+                }
+                trait B {
+                    int foo() { 2 }
+                }
+                class AB implements B,A {
+                }
+                def x = new AB()
+                assert x.foo() == 1 // default order, A is first
             '''
 
             assertScript '''
-            trait A {
-                int foo() { 1 }
-            }
-            trait B {
-                int foo() { 2 }
-            }
-            class AB implements A,B {
-                int foo() {
-                    A.super.foo() // explicit use of A
+                trait A {
+                    int foo() { 1 }
                 }
-            }
-            def x = new AB()
-            assert x.foo() == 1
+                trait B {
+                    int foo() { 2 }
+                }
+                class AB implements A,B {
+                    int foo() {
+                        A.super.foo() // explicit use of A
+                    }
+                }
+                def x = new AB()
+                assert x.foo() == 1
             '''
 
             assertScript '''
-            trait A {
-                int foo() { 1 }
-            }
-            trait B {
-                int foo() { 2 }
-            }
-            class AB implements A,B {
-                int foo() {
-                    A.super.foo()  // explicit take of A
+                trait A {
+                    int foo() { 1 }
                 }
-            }
-            def x = new AB()
-            assert x.foo() == 1
+                trait B {
+                    int foo() { 2 }
+                }
+                class AB implements A,B {
+                    int foo() {
+                        A.super.foo()  // explicit take of A
+                    }
+                }
+                def x = new AB()
+                assert x.foo() == 1
             '''
         }
 
@@ -476,6 +499,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testTraitWithGenerics1() {
         assertScript '''
             trait Provider<T> {
@@ -502,6 +526,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testTraitWithGenerics2() {
         assertScript '''
             trait Provider<T> {
@@ -528,6 +553,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testTraitWithGenericProperty() {
         assertScript '''
             trait PropertyProvider<T> {
@@ -552,6 +578,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testTraitWithComplexGenericProperty() {
         assertScript '''
             trait PropertyProvider<T> {
@@ -591,6 +618,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testTraitWithGenericField() {
         assertScript '''
             trait PropertyProvider<T> {
@@ -619,6 +647,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testRuntimeTrait() {
         assertScript '''
             trait Flying {
@@ -639,6 +668,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testRuntimeDoubleTrait() {
         assertScript '''
             trait Flying {
@@ -671,6 +701,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testRuntimeWithTraitsDGM() {
         assertScript '''
             trait Flying {
@@ -699,7 +730,8 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
-   void testRuntimeWithTraitsDGMAndExplicitOverride() {
+    @Test
+    void testRuntimeWithTraitsDGMAndExplicitOverride() {
         assertScript '''
             trait Flying {
                 String fly() {
@@ -730,7 +762,8 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
-   void testRuntimeTraitUnderCompileStaticShouldUseMethodFromTrait() {
+    @Test
+    void testRuntimeTraitUnderCompileStaticShouldUseMethodFromTrait() {
         assertScript '''
             trait Flying {
                 String fly() {
@@ -758,7 +791,8 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
-   void testRuntimeWithTraitsDGMAndExtraMethodCompileStatic() {
+    @Test
+    void testRuntimeWithTraitsDGMAndExtraMethodCompileStatic() {
         assertScript '''
             trait Flying {
                 String fly() {
@@ -789,6 +823,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testRuntimeTraitWithMethodOfTheSameSignature() {
         assertScript '''
             trait Flying {
@@ -806,10 +841,10 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
             // when using runtime traits, inherits methods from trait!
             assert d.fly() == "I'm flying!"
             assert d.ability() == 'fly'
-
         '''
     }
 
+    @Test
     void testTraitWithDelegatesTo() {
         assertScript '''
             trait Route {
@@ -833,6 +868,7 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
             '''
     }
 
+    @Test
     void testProxyGenerationShouldNotFail() {
         assertScript '''
             trait Foo { }
@@ -843,22 +879,25 @@ assert MyEnum.X.bar == 123 && MyEnum.Y.bar == 0
         '''
     }
 
+    @Test
     void testShouldNotThrowNPEWithInheritanceUsingExtends() {
         assertScript '''
-trait Named {
-    String name
-}
+            trait Named {
+                String name
+            }
 
-trait NameSpeakable extends Named {
-    String speak() { "My name is $name" }
-}
+            trait NameSpeakable extends Named {
+                String speak() { "My name is $name" }
+            }
 
-class Phone implements NameSpeakable {}
+            class Phone implements NameSpeakable {}
 
-def phone = new Phone(name: 'Galaxy S3')
-assert phone.speak() == 'My name is Galaxy S3\''''
+            def phone = new Phone(name: 'Galaxy S3')
+            assert phone.speak() == 'My name is Galaxy S3\'
+        '''
     }
 
+    @Test
     void testStaticInnerClassInTrait() {
         assertScript '''
             trait Outer {
@@ -878,49 +917,50 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testNonStaticInnerClassInTrait() {
-        shouldFail {
-            assertScript '''
-                trait Outer {
-                    Inner doSomething() {
-                        new Inner()
-                    }
+        shouldFail '''
+            trait Outer {
+                Inner doSomething() {
+                    new Inner()
                 }
-                class Foo implements Outer {}
-                def f = new Foo()
-            '''
-        }
+            }
+            class Foo implements Outer {}
+            def f = new Foo()
+        '''
     }
 
+    @Test
     void testClosureInsideTrait() {
         assertScript '''
-        trait Doubler {
-            int foo(int x) {
-                { -> 2*x }.call()
+            trait Doubler {
+                int foo(int x) {
+                    { -> 2*x }.call()
+                }
             }
-        }
-        class Foo implements Doubler {}
-        def f = new Foo()
-        assert f.foo(4) == 8
+            class Foo implements Doubler {}
+            def f = new Foo()
+            assert f.foo(4) == 8
         '''
     }
 
+    @Test
     void testClosureInsideTraitAccessingProperty() {
         assertScript '''
-
-        trait Doubler {
-            int x
-            int foo() {
-                { -> 2*x }.call()
+            trait Doubler {
+                int x
+                int foo() {
+                    { -> 2*x }.call()
+                }
             }
-        }
-        class Foo implements Doubler {}
-        def f = new Foo()
-        f.x = 4
-        assert f.foo() == 8
+            class Foo implements Doubler {}
+            def f = new Foo()
+            f.x = 4
+            assert f.foo() == 8
         '''
     }
 
+    @Test
     void testThisDotClassInTrait() {
         assertScript '''
             trait Classic {
@@ -934,6 +974,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testShouldNotThrowStackOverflow() {
         assertScript '''
             trait TestTrait {
@@ -949,7 +990,9 @@ assert phone.speak() == 'My name is Galaxy S3\''''
             foo.update('Groovy')
             assert foo.blah() == 'Groovy'
         '''
-        assertScript '''import groovy.transform.CompileStatic
+
+        assertScript '''
+            import groovy.transform.CompileStatic
             @CompileStatic
             trait TestTrait {
                 private String message = 'Hello'
@@ -971,6 +1014,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testSuperCallInTraitExtendingAnotherTrait() {
         assertScript '''
             trait Foo {
@@ -985,7 +1029,9 @@ assert phone.speak() == 'My name is Galaxy S3\''''
             def b = new Baz()
             assert b.foo() == 2
         '''
-        assertScript '''import groovy.transform.CompileStatic
+
+        assertScript '''
+            import groovy.transform.CompileStatic
             @CompileStatic
             trait Foo {
                 int foo() { 1 }
@@ -1002,6 +1048,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testTraitShouldNotTakeOverSuperClassMethod() {
         assertScript '''
             trait TestTrait {
@@ -1021,6 +1068,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testTraitShouldTakeOverSuperClassMethod() {
         assertScript '''
             trait TestTrait {
@@ -1035,6 +1083,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testOverrideUsingRuntimeTrait() {
         assertScript '''
             trait TestTrait {
@@ -1062,6 +1111,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testTraitOverrideHierarchy() {
         assertScript '''
             trait TestTrait {
@@ -1089,6 +1139,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testSAMCoercionOfTraitOnAssignment() {
         assertScript '''
             trait SAMTrait {
@@ -1112,6 +1163,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testSAMCoercionOfTraitOnMethod() {
         assertScript '''
             trait SAMTrait {
@@ -1123,6 +1175,7 @@ assert phone.speak() == 'My name is Galaxy S3\''''
             }
             test { 'hello' } // SAM coercion
         '''
+
         assertScript '''
             trait SAMTrait {
                 String foo() { bar()+bar() }
@@ -1139,28 +1192,31 @@ assert phone.speak() == 'My name is Galaxy S3\''''
         '''
     }
 
+    @Test
     void testImplicitSAMCoercionBug() {
         assertScript '''
-trait Greeter {
-    String greet() { "Hello $name" }
-    abstract String getName()
-}
-Greeter greeter = { 'Alice' }
-assert greeter.greet() == 'Hello Alice'
-'''
+            trait Greeter {
+                String greet() { "Hello $name" }
+                abstract String getName()
+            }
+            Greeter greeter = { 'Alice' }
+            assert greeter.greet() == 'Hello Alice'
+        '''
     }
 
+    @Test
     void testExplicitSAMCoercionBug() {
         assertScript '''
-trait Greeter {
-    String greet() { "Hello $name" }
-    abstract String getName()
-}
-Greeter greeter = { 'Alice' } as Greeter
-assert greeter.greet() == 'Hello Alice'
-'''
+            trait Greeter {
+                String greet() { "Hello $name" }
+                abstract String getName()
+            }
+            Greeter greeter = { 'Alice' } as Greeter
+            assert greeter.greet() == 'Hello Alice'
+        '''
     }
 
+    @Test
     void testMethodMissingInTrait() {
         assertScript '''
             trait MethodMissingProvider {
@@ -1174,6 +1230,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testPropertyMissingInTrait() {
         assertScript '''
             trait PropertyMissingProvider {
@@ -1187,6 +1244,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testShouldUseDefinitionFromClassInsteadOfTrait() {
         assertScript '''
             trait TestTrait {
@@ -1200,6 +1258,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testPrivateFieldNameConflict() {
         assertScript '''
             trait Trait1 { private int v = 111; int getValueFromTrait1() { v } }
@@ -1211,6 +1270,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testPrivateMethodInTrait() {
         assertScript '''
             trait DoingSecretThings {
@@ -1223,6 +1283,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testPrivateMethodInTraitAccessingPrivateField() {
         assertScript '''
             trait DoingSecretThings {
@@ -1236,6 +1297,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testPrivateMethodInTraitWithCompileStatic() {
         assertScript '''
             @groovy.transform.CompileStatic
@@ -1249,6 +1311,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testPrivateMethodInTraitAccessingPrivateFieldCompileStatic() {
         assertScript '''
             @groovy.transform.CompileStatic
@@ -1264,6 +1327,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testNoShadowingPrivateMethodInTraitAccessingPrivateFieldCompileStatic() {
         assertScript '''
             @groovy.transform.CompileStatic
@@ -1281,6 +1345,7 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testNoShadowingPrivateMethodInTraitAccessingPrivateField() {
         assertScript '''
             trait DoingSecretThings {
@@ -1297,9 +1362,9 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testMixPrivatePublicMethodsOfSameName() {
-        shouldFail {
-            assertScript '''
+        def err = shouldFail '''
             trait DoingSecretThings {
                 private String secret(String s) { s.toUpperCase() }
                 String secret() { 'public' }
@@ -1309,9 +1374,11 @@ assert greeter.greet() == 'Hello Alice'
             def foo = new Foo()
             assert foo.foo() == 'SECRET'
         '''
-        } =~ 'Mixing private and public/protected methods of the same name causes multimethods to be disabled'
+
+        assert err =~ 'Mixing private and public/protected methods of the same name causes multimethods to be disabled'
     }
 
+    @Test
     void testInterfaceExtendingTraitShouldNotTriggerRuntimeError() {
         assertScript '''
             trait A {
@@ -1332,24 +1399,27 @@ assert greeter.greet() == 'Hello Alice'
         '''
     }
 
+    @Test
     void testTraitWithDelegate() {
         assertScript '''
-trait ListTrait<T> {
-    private @Delegate ArrayList<T> list = new ArrayList<T>()
-}
-class Person implements ListTrait<String> {
-    void foo() {
-        add('bar')
-    }
-}
-def p = new Person()
-p.foo()
-assert p.get(0) == 'bar'
-'''
+            trait ListTrait<T> {
+                private @Delegate ArrayList<T> list = new ArrayList<T>()
+            }
+            class Person implements ListTrait<String> {
+                void foo() {
+                    add('bar')
+                }
+            }
+            def p = new Person()
+            p.foo()
+            assert p.get(0) == 'bar'
+        '''
     }
 
+    @Test
     void testAnnotationShouldBeCarriedOver() {
-        assertScript '''import groovy.transform.ASTTest
+        assertScript '''
+            import groovy.transform.ASTTest
 
             trait Foo {
                 @Deprecated void foo() { 'ok' }
@@ -1363,16 +1433,18 @@ assert p.get(0) == 'bar'
         '''
     }
 
+    @Test
     void testShouldCompileTraitMethodStatically() {
-        def message = shouldFail '''
+        def err = shouldFail '''
             @groovy.transform.CompileStatic
             trait Foo {
                 int foo() { 1+'foo'}
             }
         '''
-        assert message.contains('[Static type checking] - Cannot return value of type java.lang.String on method returning type int')
+        assert err =~ 'Cannot return value of type java.lang.String on method returning type int'
     }
 
+    @Test
     void testStaticMethodInTrait() {
         assertScript '''
             trait StaticProvider {
@@ -1381,6 +1453,7 @@ assert p.get(0) == 'bar'
             class Foo implements StaticProvider {}
             assert Foo.foo() == 'static method'
         '''
+
         assertScript '''
             trait StaticProvider {
                 static String foo() { bar() }
@@ -1391,284 +1464,304 @@ assert p.get(0) == 'bar'
         '''
     }
 
+    @Test
     void testStaticFieldInTrait() {
         assertScript '''
-trait StaticFieldProvider {
-    public static int VAL = 123
-}
-class Foo implements StaticFieldProvider {}
-assert Foo.StaticFieldProvider__VAL == 123
-'''
+            trait StaticFieldProvider {
+                public static int VAL = 123
+            }
+            class Foo implements StaticFieldProvider {}
+            assert Foo.StaticFieldProvider__VAL == 123
+        '''
     }
 
+    @Test
     void testStaticFieldModifiedInTrait() {
         assertScript '''
-trait StaticFieldProvider {
-    public static int VAL = 123
-    public static void update(int x) { VAL = x }
-}
-class Foo implements StaticFieldProvider {}
-assert Foo.StaticFieldProvider__VAL == 123
-Foo.update(456)
-assert Foo.StaticFieldProvider__VAL == 456
-'''
+            trait StaticFieldProvider {
+                public static int VAL = 123
+                public static void update(int x) { VAL = x }
+            }
+            class Foo implements StaticFieldProvider {}
+            assert Foo.StaticFieldProvider__VAL == 123
+            Foo.update(456)
+            assert Foo.StaticFieldProvider__VAL == 456
+        '''
     }
 
+    @Test
     void testStaticPropertyModifiedInTrait() {
         assertScript '''
-trait StaticFieldProvider {
-    static int VAL = 123
-    public static void update(int x) { VAL = x }
-}
-class Foo implements StaticFieldProvider {}
-assert Foo.VAL == 123
-Foo.update(456)
-assert Foo.VAL == 456
-'''
+            trait StaticFieldProvider {
+                static int VAL = 123
+                public static void update(int x) { VAL = x }
+            }
+            class Foo implements StaticFieldProvider {}
+            assert Foo.VAL == 123
+            Foo.update(456)
+            assert Foo.VAL == 456
+        '''
     }
 
+    @Test
     void testTraitMethodShouldBeDefaultImplementationUsingReflection() {
-        assertScript '''import org.codehaus.groovy.transform.trait.Traits
+        assertScript '''
+            import org.codehaus.groovy.transform.trait.Traits
 
-trait Foo {
-    void foo() {}
-}
+            trait Foo {
+                void foo() {}
+            }
 
-class Bar implements Foo {}
+            class Bar implements Foo {}
 
-def method = Bar.getDeclaredMethod('foo')
-assert method.declaringClass == Bar
-assert Traits.isBridgeMethod(method)
-def traitMethod = Traits.getBridgeMethodTarget(method)
-assert traitMethod != null
-assert traitMethod.declaringClass == Foo
-assert traitMethod.name == 'foo'
-'''
+            def method = Bar.getDeclaredMethod('foo')
+            assert method.declaringClass == Bar
+            assert Traits.isBridgeMethod(method)
+            def traitMethod = Traits.getBridgeMethodTarget(method)
+            assert traitMethod != null
+            assert traitMethod.declaringClass == Foo
+            assert traitMethod.name == 'foo'
+        '''
     }
 
+    @Test
     void testTraitMethodShouldNotBeDefaultImplementationUsingReflection() {
-        assertScript '''import org.codehaus.groovy.transform.trait.Traits
+        assertScript '''
+            import org.codehaus.groovy.transform.trait.Traits
 
-trait Foo {
-    void foo() {}
-}
+            trait Foo {
+                void foo() {}
+            }
 
-class Bar implements Foo {
-    void foo() { }
-}
+            class Bar implements Foo {
+                void foo() { }
+            }
 
-def method = Bar.getDeclaredMethod('foo')
-assert method.declaringClass == Bar
-assert !Traits.isBridgeMethod(method)
-def traitMethod = Traits.getBridgeMethodTarget(method)
-assert traitMethod == null
-'''
+            def method = Bar.getDeclaredMethod('foo')
+            assert method.declaringClass == Bar
+            assert !Traits.isBridgeMethod(method)
+            def traitMethod = Traits.getBridgeMethodTarget(method)
+            assert traitMethod == null
+        '''
     }
 
+    @Test
     void testTraitMethodShouldBeDefaultImplementationUsingReflectionAndGenericTypes() {
-        assertScript '''import org.codehaus.groovy.transform.trait.Traits
+        assertScript '''
+            import org.codehaus.groovy.transform.trait.Traits
 
-trait Foo<F,T> {
-    T foo(F from) {}
-}
+            trait Foo<F,T> {
+                T foo(F from) {}
+            }
 
-class Bar implements Foo<String,Integer> {}
+            class Bar implements Foo<String,Integer> {}
 
-def method = Bar.getDeclaredMethod('foo', String)
-assert method.declaringClass == Bar
-assert Traits.isBridgeMethod(method)
-def traitMethod = Traits.getBridgeMethodTarget(method)
-assert traitMethod != null
-assert traitMethod.declaringClass == Foo
-assert traitMethod.name == 'foo'
-assert traitMethod.parameterTypes.length==1
-assert traitMethod.parameterTypes[0] == Object
-'''
+            def method = Bar.getDeclaredMethod('foo', String)
+            assert method.declaringClass == Bar
+            assert Traits.isBridgeMethod(method)
+            def traitMethod = Traits.getBridgeMethodTarget(method)
+            assert traitMethod != null
+            assert traitMethod.declaringClass == Foo
+            assert traitMethod.name == 'foo'
+            assert traitMethod.parameterTypes.length==1
+            assert traitMethod.parameterTypes[0] == Object
+        '''
     }
 
+    @Test
     void testUseOfThisInInitializer() {
         assertScript '''
-trait Dummyable  {
-    String x = this.class.name
-
-    void info() {
-        assert x == this.class.name
-    }
-}
+            trait Dummyable  {
+                String x = this.class.name
 
+                void info() {
+                    assert x == this.class.name
+                }
+            }
 
-class Util implements Dummyable {}
+            class Util implements Dummyable {}
 
-def util = new Util()
-util.info()'''
+            def util = new Util()
+            util.info()
+        '''
     }
 
+    @Test
     void testUseOfMethodInInitializer() {
         assertScript '''
-trait Dummyable  {
-    String x = whoAmI()
+            trait Dummyable  {
+                String x = whoAmI()
 
-    String whoAmI() { this.class.name }
+                String whoAmI() { this.class.name }
 
-    void info() {
-        assert x == this.class.name
-    }
-}
+                void info() {
+                    assert x == this.class.name
+                }
+            }
 
 
-class Util implements Dummyable {}
+            class Util implements Dummyable {}
 
-def util = new Util()
-util.info()'''
+            def util = new Util()
+            util.info()
+        '''
     }
 
+    @Test
     void testTraitShouldNotBeAllowedToExtendInterface() {
         // GROOVY-6672
-        def message = shouldFail '''
+        def err = shouldFail '''
             trait Foo extends Serializable {}
             Foo x = null
         '''
-        assert message.contains('Trait cannot extend an interface.')
+        assert err =~ 'Trait cannot extend an interface.'
     }
 
+    @Test
     void testImplementingingAbstractClass() {
         assertScript '''
-abstract class AbstractSomething {
-    abstract String something()
-}
-
-trait SomethingDoing {
-    String something() {
-        "Doing something"
-    }
-}
+            abstract class AbstractSomething {
+                abstract String something()
+            }
 
-class Something extends AbstractSomething implements SomethingDoing {
-    String foo() {
-        something()
-    }
-}
+            trait SomethingDoing {
+                String something() {
+                    "Doing something"
+                }
+            }
 
-assert new Something().foo() == 'Doing something'
+            class Something extends AbstractSomething implements SomethingDoing {
+                String foo() {
+                    something()
+                }
+            }
 
-'''
+            assert new Something().foo() == 'Doing something'
+        '''
     }
 
+    @Test
     void testShouldNotOverrideMethodImplementedFromAbstractClass() {
         assertScript '''
-abstract class AbstractSomething {
-    abstract String something()
-}
-
-trait SomethingDoing {
-    String something() {
-        "Doing something"
-    }
-}
+            abstract class AbstractSomething {
+                abstract String something()
+            }
 
-class Something extends AbstractSomething  {
-    String something() { 'implemented' }
-}
+            trait SomethingDoing {
+                String something() {
+                    "Doing something"
+                }
+            }
 
-class BottomSomething extends Something implements SomethingDoing {
-    String something() {
-        // in order to avoid getting the default impl from the trait, need to call super
-        super.something()
-    }
-    String foo() {
-        something()
-    }
-}
+            class Something extends AbstractSomething  {
+                String something() { 'implemented' }
+            }
 
-assert new BottomSomething().foo() == 'implemented'
+            class BottomSomething extends Something implements SomethingDoing {
+                String something() {
+                    // in order to avoid getting the default impl from the trait, need to call super
+                    super.something()
+                }
+                String foo() {
+                    something()
+                }
+            }
 
-'''
+            assert new BottomSomething().foo() == 'implemented'
+        '''
     }
 
+    @Test
     void testIncrementPropertyOfTrait() {
-        assertScript '''trait Level {
-    int maxLevel
-    int currentLevel = 0
+        assertScript '''
+            trait Level {
+                int maxLevel
+                int currentLevel = 0
 
-    void foo() {
-        if( currentLevel < maxLevel ) {
-            currentLevel += 1
-        }
-    }
-}
+                void foo() {
+                    if( currentLevel < maxLevel ) {
+                        currentLevel += 1
+                    }
+                }
+            }
 
-class Leveller implements Level {
-    Leveller() {
-        maxLevel = 3
-    }
-}
+            class Leveller implements Level {
+                Leveller() {
+                    maxLevel = 3
+                }
+            }
 
-def v = new Leveller()
-v.foo()
-v.foo()
-v.foo()
-v.foo()
-assert v.currentLevel == 3
-'''
+            def v = new Leveller()
+            v.foo()
+            v.foo()
+            v.foo()
+            v.foo()
+            assert v.currentLevel == 3
+        '''
     }
 
     void testIncrementPropertyOfTraitUsingPlusPlus() {
-        def message = shouldFail '''trait Level {
-    int maxLevel
-    int currentLevel = 0
+        def err = shouldFail '''
+            trait Level {
+                int maxLevel
+                int currentLevel = 0
 
-    void foo() {
-        if( currentLevel < maxLevel ) {
-            currentLevel++
-        }
-    }
-}
+                void foo() {
+                    if( currentLevel < maxLevel ) {
+                        currentLevel++
+                    }
+                }
+            }
 
-class Leveller implements Level {
-    Leveller() {
-        maxLevel = 3
-    }
-}
+            class Leveller implements Level {
+                Leveller() {
+                    maxLevel = 3
+                }
+            }
+
+            def v = new Leveller()
+            v.foo()
+            v.foo()
+            v.foo()
+            v.foo()
+            assert v.currentLevel == 3
+        '''
 
-def v = new Leveller()
-v.foo()
-v.foo()
-v.foo()
-v.foo()
-assert v.currentLevel == 3
-'''
-        assert message.contains('Postfix expressions on trait fields/properties  are not supported in traits')
+        assert err =~ 'Postfix expressions on trait fields/properties  are not supported in traits'
     }
 
+    @Test
     void testIncrementPropertyOfTraitUsingPrefixPlusPlus() {
-        def message = shouldFail '''trait Level {
-    int maxLevel
-    int currentLevel = 0
+        def err = shouldFail '''
+            trait Level {
+                int maxLevel
+                int currentLevel = 0
 
-    void foo() {
-        if( currentLevel < maxLevel ) {
-            ++currentLevel
-        }
-    }
-}
+                void foo() {
+                    if( currentLevel < maxLevel ) {
+                        ++currentLevel
+                    }
+                }
+            }
 
-class Leveller implements Level {
-    Leveller() {
-        maxLevel = 3
-    }
-}
+            class Leveller implements Level {
+                Leveller() {
+                    maxLevel = 3
+                }
+            }
+
+            def v = new Leveller()
+            v.foo()
+            v.foo()
+            v.foo()
+            v.foo()
+            assert v.currentLevel == 3
+        '''
 
-def v = new Leveller()
-v.foo()
-v.foo()
-v.foo()
-v.foo()
-assert v.currentLevel == 3
-'''
-        assert message.contains('Prefix expressions on trait fields/properties are not supported in traits')
+        assert err =~ 'Prefix expressions on trait fields/properties are not supported in traits'
     }
 
-    // GROOVY-6691
+    @Test // GROOVY-6691
     void testTraitImplementingGenericSuperTrait() {
         assertScript '''
             class App {}
@@ -1686,7 +1779,8 @@ assert v.currentLevel == 3
             }
             test()
         '''
-        def message = shouldFail '''
+
+        def err = shouldFail '''
             class App {}
             trait Base<T> {
                 T value
@@ -1702,9 +1796,11 @@ assert v.currentLevel == 3
             }
             test()
         '''
-        assert message.contains('Cannot find matching method Dummy#set(java.lang.String)')
+
+        assert err =~ 'Cannot find matching method Dummy#set\\(java.lang.String\\)'
     }
 
+    @Test
     void testUpdateFieldFromOtherReceiver() {
         assertScript '''
             class Person {
@@ -1723,6 +1819,7 @@ assert v.currentLevel == 3
         '''
     }
 
+    @Test
     void testUseStaticFieldInTraitBody() {
         assertScript '''
             import java.util.logging.Logger
@@ -1743,6 +1840,7 @@ assert v.currentLevel == 3
         '''
     }
 
+    @Test
     void testUpdateStaticFieldInTraitBody() {
         assertScript '''
             trait Loggable {
@@ -1764,401 +1862,420 @@ assert v.currentLevel == 3
         '''
     }
 
+    @Test
     void testProxyTarget() {
         assertScript '''
-trait Helloable implements CharSequence {
-    void hello() { println "hello" }
-}
-
-def x = new String("hello") as Helloable
-x.hello()
-assert !(x instanceof String)
-assert x instanceof Helloable
-assert x instanceof GeneratedGroovyProxy
-assert x.toUpperCase() == "HELLO" // expected
-assert x.proxyTarget.tr('h','*') == "*ello"
-'''
+            trait Helloable implements CharSequence {
+                void hello() { println "hello" }
+            }
 
+            def x = new String("hello") as Helloable
+            x.hello()
+            assert !(x instanceof String)
+            assert x instanceof Helloable
+            assert x instanceof GeneratedGroovyProxy
+            assert x.toUpperCase() == "HELLO" // expected
+            assert x.proxyTarget.tr('h','*') == "*ello"
+        '''
     }
 
+    @Test
     void testTraitsGetAsType() {
-        assertScript '''import org.codehaus.groovy.transform.trait.Traits
-trait Helloable implements CharSequence {
-    void hello() { println "hello" }
-}
-def str = "hello"
-def x = str as Helloable
-x.hello()
-assert !(x instanceof String)
-assert x instanceof Helloable
-assert x instanceof GeneratedGroovyProxy
-assert x.toUpperCase() == "HELLO" // expected
-assert x.proxyTarget.tr('h','*') == "*ello"
-def proxyTarget = x.proxyTarget
-assert proxyTarget.is(str)
-def converted = Traits.getAsType(x,String)
-assert converted.is(str)
-'''
+        assertScript '''
+            import org.codehaus.groovy.transform.trait.Traits
+            trait Helloable implements CharSequence {
+                void hello() { println "hello" }
+            }
+            def str = "hello"
+            def x = str as Helloable
+            x.hello()
+            assert !(x instanceof String)
+            assert x instanceof Helloable
+            assert x instanceof GeneratedGroovyProxy
+            assert x.toUpperCase() == "HELLO" // expected
+            assert x.proxyTarget.tr('h','*') == "*ello"
+            def proxyTarget = x.proxyTarget
+            assert proxyTarget.is(str)
+            def converted = Traits.getAsType(x,String)
+            assert converted.is(str)
+        '''
     }
 
+    @Test
     void testStackableTraits() {
-        assertScript '''import org.codehaus.groovy.transform.trait.Traits
+        assertScript '''
+            import org.codehaus.groovy.transform.trait.Traits
 
-trait A {
-    int foo(int x) { x }
-}
-trait B {
-    int foo(int x) { x<10?2*super.foo(x):x }
-}
-class C implements A,B {}
-def c = new C()
-(0..9).each {
-    assert c.foo(it) == 2*it
-}
-(10..20).each {
-    assert c.foo(it) == it
-}'''
+            trait A {
+                int foo(int x) { x }
+            }
+            trait B {
+                int foo(int x) { x<10?2*super.foo(x):x }
+            }
+            class C implements A,B {}
+            def c = new C()
+            (0..9).each {
+                assert c.foo(it) == 2*it
+            }
+            (10..20).each {
+                assert c.foo(it) == it
+            }
+        '''
     }
 
+    @Test
     void testStackableTraitsWithExplicitClasses() {
         assertScript '''
+            interface IntQueue {
+                Integer get()
+                void put(Integer x)
+            }
+            trait Incrementing {
+                void put(Integer x) { println 'Incrementing';super.put(x+1) }
+            }
+            trait Filtering {
+                void put(Integer x) { println 'Filtering'; if(x >=0) super.put(x) }
+            }
 
-interface IntQueue {
-    Integer get()
-    void put(Integer x)
-}
-trait Incrementing {
-    void put(Integer x) { println 'Incrementing';super.put(x+1) }
-}
-trait Filtering {
-    void put(Integer x) { println 'Filtering'; if(x >=0) super.put(x) }
-}
-
-class BasicIntQueue implements IntQueue{
-    private buf = new ArrayList<Integer>()
-    Integer get() { buf.remove(0) }
-    void put(Integer x) { buf << x}
-    String toString() { buf.toString() }
-}
-class Sub extends BasicIntQueue implements Incrementing, Filtering {}
-
-def queue = new Sub()
-//queue.put(-1) // filtering -> sink
-queue.put(0) // filtering ok -> incrementing.put -> 1
-queue.put(1)  // filtering ok -> goes to incrementing.put -> 2
-assert queue.get() == 1
-assert queue.get() == 2
-assert queue.toString() == "[]"
+            class BasicIntQueue implements IntQueue{
+                private buf = new ArrayList<Integer>()
+                Integer get() { buf.remove(0) }
+                void put(Integer x) { buf << x}
+                String toString() { buf.toString() }
+            }
+            class Sub extends BasicIntQueue implements Incrementing, Filtering {}
 
-class Sub2 extends BasicIntQueue implements Filtering, Incrementing {}
+            def queue = new Sub()
+            //queue.put(-1) // filtering -> sink
+            queue.put(0) // filtering ok -> incrementing.put -> 1
+            queue.put(1)  // filtering ok -> goes to incrementing.put -> 2
+            assert queue.get() == 1
+            assert queue.get() == 2
+            assert queue.toString() == "[]"
 
-def queue2 = new Sub2()
-queue2.put(-1) // incrementing -> put(0) -> filtering ok -> 0
-queue2.put(0) // incrementing -> put(1) -> filtering ok -> 1
-queue2.put(1) // incrementing -> put(2) -> filtering ok -> 2
-assert queue2.get() == 0
-assert queue2.get() == 1
-assert queue2.get() == 2
-assert queue2.toString() == "[]"
+            class Sub2 extends BasicIntQueue implements Filtering, Incrementing {}
 
-'''
+            def queue2 = new Sub2()
+            queue2.put(-1) // incrementing -> put(0) -> filtering ok -> 0
+            queue2.put(0) // incrementing -> put(1) -> filtering ok -> 1
+            queue2.put(1) // incrementing -> put(2) -> filtering ok -> 2
+            assert queue2.get() == 0
+            assert queue2.get() == 1
+            assert queue2.get() == 2
+            assert queue2.toString() == "[]"
+        '''
     }
 
+    @Test
     void testStackableTraitsWithDynamicTraits() {
         assertScript '''
+            interface IntQueue {
+                Integer get()
+                void put(Integer x)
+            }
+            trait Incrementing {
+                void put(Integer x) { println 'Incrementing';super.put(x+1) }
+            }
+            trait Filtering {
+                void put(Integer x) { println 'Filtering'; if(x >=0) super.put(x) }
+            }
 
-interface IntQueue {
-    Integer get()
-    void put(Integer x)
-}
-trait Incrementing {
-    void put(Integer x) { println 'Incrementing';super.put(x+1) }
-}
-trait Filtering {
-    void put(Integer x) { println 'Filtering'; if(x >=0) super.put(x) }
-}
+            class BasicIntQueue implements IntQueue{
+                private buf = new ArrayList<Integer>()
+                Integer get() { buf.remove(0) }
+                void put(Integer x) { buf << x}
+                String toString() { buf.toString() }
+            }
 
-class BasicIntQueue implements IntQueue{
-    private buf = new ArrayList<Integer>()
-    Integer get() { buf.remove(0) }
-    void put(Integer x) { buf << x}
-    String toString() { buf.toString() }
-}
+            def queue = new BasicIntQueue().withTraits Incrementing, Filtering
+            queue.put(-1) // filtering -> skink
+            queue.put(0) // filtering ok -> incrementing -> [1]
+            queue.put(1) // filtering ok -> incrementing -> [1,2]
+            assert queue.get() == 1
+            assert queue.get() == 2
+            assert queue.proxyTarget.toString() == "[]"
 
-def queue = new BasicIntQueue().withTraits Incrementing, Filtering
-queue.put(-1) // filtering -> skink
-queue.put(0) // filtering ok -> incrementing -> [1]
-queue.put(1) // filtering ok -> incrementing -> [1,2]
-assert queue.get() == 1
-assert queue.get() == 2
-assert queue.proxyTarget.toString() == "[]"
-
-def queue2 = new BasicIntQueue().withTraits Filtering, Incrementing
-queue2.put(-1) // incrementing -> 0 -> filtering -> ok -> [0]
-queue2.put(0) // incrementing -> 1 -> filtering ok -> [0,1]
-queue2.put(1) // incrementing -> 2 -> filtering ok -> [0,1,2]
-assert queue2.get() == 0
-assert queue2.get() == 1
-assert queue2.get() == 2
-assert queue.proxyTarget.toString() == "[]"
-'''
+            def queue2 = new BasicIntQueue().withTraits Filtering, Incrementing
+            queue2.put(-1) // incrementing -> 0 -> filtering -> ok -> [0]
+            queue2.put(0) // incrementing -> 1 -> filtering ok -> [0,1]
+            queue2.put(1) // incrementing -> 2 -> filtering ok -> [0,1,2]
+            assert queue2.get() == 0
+            assert queue2.get() == 1
+            assert queue2.get() == 2
+            assert queue.proxyTarget.toString() == "[]"
+        '''
     }
 
+    @Test
     void testSuperKeywordInRegularTraitInheritance() {
         assertScript '''
-trait A {
-    int foo(x) { 1+x }
-}
-trait B extends A {
-    int foo(x) { 2*super.foo(x)}
-}
-class C implements B {}
-def c = new C()
-assert c.foo(2) == 6
-'''
+            trait A {
+                int foo(x) { 1+x }
+            }
+            trait B extends A {
+                int foo(x) { 2*super.foo(x)}
+            }
+            class C implements B {}
+            def c = new C()
+            assert c.foo(2) == 6
+        '''
     }
 
+    @Test
     void testSuperKeywordInRegularTraitMultipleInheritance() {
         assertScript '''
-trait A {
-    int foo(x) { 1+x }
-}
-trait A2 {
-    int foo(x) { 1+super.foo(x) }
-}
-trait B implements A,A2 {
-    int foo(x) { 2*super.foo(x)}
-}
-class C implements B {}
-def c = new C()
-assert c.foo(2) == 8
-'''
+            trait A {
+                int foo(x) { 1+x }
+            }
+            trait A2 {
+                int foo(x) { 1+super.foo(x) }
+            }
+            trait B implements A,A2 {
+                int foo(x) { 2*super.foo(x)}
+            }
+            class C implements B {}
+            def c = new C()
+            assert c.foo(2) == 8
+        '''
     }
 
+    @Test
     void testStaticallyCompiledTraitWithCallToSuper() {
         assertScript '''
-@groovy.transform.CompileStatic
-trait A {
-    int foo(int x) { 1+x }
-}
-@groovy.transform.CompileStatic
-trait B extends A {
-    int foo(int x) { 2*super.foo(x)}
-}
-class C implements B {}
-def c = new C()
-assert c.foo(2) == 6
-'''
+            @groovy.transform.CompileStatic
+            trait A {
+                int foo(int x) { 1+x }
+            }
+            @groovy.transform.CompileStatic
+            trait B extends A {
+                int foo(int x) { 2*super.foo(x)}
+            }
+            class C implements B {}
+            def c = new C()
+            assert c.foo(2) == 6
+        '''
     }
 
+    @Test
     void testStaticallyCompiledTraitWithCallToSuperInPackage() {
-        assertScript '''package blah
-@groovy.transform.CompileStatic
-trait A {
-    int foo(int x) { 1+x }
-}
-@groovy.transform.CompileStatic
-trait B extends A {
-    int foo(int x) { 2*super.foo(x)}
-}
-class C implements B {}
-def c = new C()
-assert c.foo(2) == 6
-'''
+        assertScript '''
+            package blah
+            @groovy.transform.CompileStatic
+            trait A {
+                int foo(int x) { 1+x }
+            }
+            @groovy.transform.CompileStatic
+            trait B extends A {
+                int foo(int x) { 2*super.foo(x)}
+            }
+            class C implements B {}
+            def c = new C()
+            assert c.foo(2) == 6
+        '''
     }
 
+    @Test
     void testStaticallyCompiledTraitWithCallToSuperInPackageAndUnderscoreInClassName() {
-        assertScript '''package blah
-@groovy.transform.CompileStatic
-trait A {
-    int foo(int x) { 1+x }
-}
-@groovy.transform.CompileStatic
-trait B_B extends A {
-    int foo(int x) { 2*super.foo(x)}
-}
-class C implements B_B {}
-def c = new C()
-assert c.foo(2) == 6
-'''
+        assertScript '''
+            package blah
+            @groovy.transform.CompileStatic
+            trait A {
+                int foo(int x) { 1+x }
+            }
+            @groovy.transform.CompileStatic
+            trait B_B extends A {
+                int foo(int x) { 2*super.foo(x)}
+            }
+            class C implements B_B {}
+            def c = new C()
+            assert c.foo(2) == 6
+        '''
     }
 
+    @Test
     void testStaticallyCompiledTraitWithCallToSuperAndNoExplicitSuperTrait() {
         assertScript '''
-@groovy.transform.CompileStatic
-trait A {
-    int foo(int x) { 1+x }
-}
-@groovy.transform.CompileStatic
-trait B {
-    int foo(int x) { 2*(int)super.foo(x)}
-}
-class C implements A,B {}
-def c = new C()
-assert c.foo(2) == 6
-'''
+            @groovy.transform.CompileStatic
+            trait A {
+                int foo(int x) { 1+x }
+            }
+            @groovy.transform.CompileStatic
+            trait B {
+                int foo(int x) { 2*(int)super.foo(x)}
+            }
+            class C implements A,B {}
+            def c = new C()
+            assert c.foo(2) == 6
+        '''
     }
 
+    @Test
     void testFieldInTraitAndDynamicProxy() {
         assertScript '''
-trait WithName {
-    public String name
-}
-WithName p = new Object() as WithName
-p.WithName__name = 'foo'
-assert p.WithName__name == 'foo'
-'''
+            trait WithName {
+                public String name
+            }
+            WithName p = new Object() as WithName
+            p.WithName__name = 'foo'
+            assert p.WithName__name == 'foo'
+        '''
     }
 
+    @Test
     void testFieldInTraitModifiers() {
-        assertScript '''import groovy.transform.ASTTest
-import static org.codehaus.groovy.control.CompilePhase.INSTRUCTION_SELECTION
-trait A {
-    public int foo
-}
-@ASTTest(phase=INSTRUCTION_SELECTION,value={
-    def field = node.getField('A__foo')
-    assert field.isPublic()
-})
-class B implements A {}
-def b = new B()
-'''
-        assertScript '''import groovy.transform.ASTTest
-
-import java.lang.reflect.Modifier
-
-import static org.codehaus.groovy.control.CompilePhase.INSTRUCTION_SELECTION
-trait A {
-    private int foo
-}
-@ASTTest(phase=INSTRUCTION_SELECTION,value={
-    def field = node.getField('A__foo')
-    assert Modifier.isPrivate(field.modifiers)
-})
-class B implements A {}
-def b = new B()
-'''
-    }
+        assertScript '''
+            import groovy.transform.ASTTest
+            import static org.codehaus.groovy.control.CompilePhase.INSTRUCTION_SELECTION
+            trait A {
+                public int foo
+            }
+            @ASTTest(phase=INSTRUCTION_SELECTION,value={
+                def field = node.getField('A__foo')
+                assert field.isPublic()
+            })
+            class B implements A {}
+            def b = new B()
+        '''
 
-    void testDecorateFinalClassWithTrait() {
         assertScript '''
-trait Filtering {
-    StringBuilder append(String str) {
-        def subst = str.replace('o','')
-        super.append(subst)
+            import groovy.transform.ASTTest
+            import java.lang.reflect.Modifier
+
+            import static org.codehaus.groovy.control.CompilePhase.INSTRUCTION_SELECTION
+            trait A {
+                private int foo
+            }
+            @ASTTest(phase=INSTRUCTION_SELECTION,value={
+                def field = node.getField('A__foo')
+                assert Modifier.isPrivate(field.modifiers)
+            })
+            class B implements A {}
+            def b = new B()
+        '''
     }
-    String toString() { super.toString() }
-}
-def sb = new StringBuilder().withTraits Filtering
-sb.append('Groovy')
-assert sb.toString() == 'Grvy'
 
-'''
+    @Test
+    void testDecorateFinalClassWithTrait() {
+        assertScript '''
+            trait Filtering {
+                StringBuilder append(String str) {
+                    def subst = str.replace('o','')
+                    super.append(subst)
+                }
+                String toString() { super.toString() }
+            }
+            def sb = new StringBuilder().withTraits Filtering
+            sb.append('Groovy')
+            assert sb.toString() == 'Grvy'
+        '''
     }
 
-    // GROOVY-6708
+    @Test // GROOVY-6708
     void testCovariantReturnTypeWithGenericsInheritance() {
         assertScript '''
-trait Top<X> {
-    X self(X x) {x}
-}
-trait Bottom<X> extends Top<X> {}
-class A implements Bottom<Integer> {}
-def a = new A()
-assert a.self(15) == 15
-'''
+            trait Top<X> {
+                X self(X x) {x}
+            }
+            trait Bottom<X> extends Top<X> {}
+            class A implements Bottom<Integer> {}
+            def a = new A()
+            assert a.self(15) == 15
+        '''
     }
 
+    @Test
     void testSuperCallInTraitAndDeepHierarchy() {
         assertScript '''
-interface IntQueue {
-    Integer get()
-    void put(Integer x)
-}
+            interface IntQueue {
+                Integer get()
+                void put(Integer x)
+            }
 
-trait Incrementing/* implements IntQueue */{
-    void put(Integer x) {
-        println 'Incrementing'
-        super.put(x+1)
-    }
-}
-trait Filtering/* implements IntQueue */{
-    void put(Integer x) {
-        println 'Filtering'
-        if(x > 0) {
-          println "Value $x, delegating to super"
-          super.put(x)
-       }
-    }
-}
+            trait Incrementing/* implements IntQueue */{
+                void put(Integer x) {
+                    println 'Incrementing'
+                    super.put(x+1)
+                }
+            }
+            trait Filtering/* implements IntQueue */{
+                void put(Integer x) {
+                    println 'Filtering'
+                    if(x > 0) {
+                      println "Value $x, delegating to super"
+                      super.put(x)
+                   }
+                }
+            }
 
-class BasicIntQueue implements IntQueue {
-    private buf = new ArrayList<Integer>()
-    Integer get() { buf.remove(0) }
-    void put(Integer x) { println 'BasicIntQueue'; buf << x}
-    String toString() { buf.toString() }
-}
+            class BasicIntQueue implements IntQueue {
+                private buf = new ArrayList<Integer>()
+                Integer get() { buf.remove(0) }
+                void put(Integer x) { println 'BasicIntQueue'; buf << x}
+                String toString() { buf.toString() }
+            }
 
-class IncrementingQueue extends BasicIntQueue implements Incrementing {}
-class FilteringIncrementingQueue extends IncrementingQueue implements Filtering {}
+            class IncrementingQueue extends BasicIntQueue implements Incrementing {}
+            class FilteringIncrementingQueue extends IncrementingQueue implements Filtering {}
 
-def queue = new FilteringIncrementingQueue()
-queue.put(-1)
-queue.put(0)
-queue.put(1)
-assert queue.get() == 2
-assert queue.toString() == "[]"
-'''
+            def queue = new FilteringIncrementingQueue()
+            queue.put(-1)
+            queue.put(0)
+            queue.put(1)
+            assert queue.get() == 2
+            assert queue.toString() == "[]"
+        '''
     }
 
+    @Test
     void testCallToSuperTraitWithStackable() {
-        assertScript '''trait T2 {
-    void foo() {
-        println 'T2'
-        super.foo()
-    }
-}
-trait T3 {
-    void foo() {
-        println 'T3'
-        super.foo()
-    }
-}
-class D implements T2, T3 {
-    void foo() {
-        T3.super.foo() // explicit call
-        println "D::foo"
-    }
-}
-def d = new D()
-try {
-d.foo()
-} catch (MissingMethodException) {
-    // will fail because T2 calls super.foo() and D.super doesn't define foo
-}
-'''
+        assertScript '''
+            trait T2 {
+                void foo() {
+                    println 'T2'
+                    super.foo()
+                }
+            }
+            trait T3 {
+                void foo() {
+                    println 'T3'
+                    super.foo()
+                }
+            }
+            class D implements T2, T3 {
+                void foo() {
+                    T3.super.foo() // explicit call
+                    println "D::foo"
+                }
+            }
+            def d = new D()
+            try {
+            d.foo()
+            } catch (MissingMethodException) {
+                // will fail because T2 calls super.foo() and D.super doesn't define foo
+            }
+        '''
     }
 
-    // GROOVY-7058
+    @Test // GROOVY-7058
     void testShouldNotThrowNPEBecauseOfIncompleteGenericsTypeInformation() {
         assertScript '''
-    class Project { Task task(String name, Map args) {} }
-    class Task {}
-    interface Plugin<P>{}
-    trait PluginUtils {
-        abstract Project getProject()
+            class Project { Task task(String name, Map args) {} }
+            class Task {}
+            interface Plugin<P>{}
+            trait PluginUtils {
+                abstract Project getProject()
 
-        public <T extends Task> T createTask(String name, Class<T> type, Closure<?> config) {
-          project.task(name, type: type, config)
-        }
-    }
+                public <T extends Task> T createTask(String name, Class<T> type, Closure<?> config) {
+                  project.task(name, type: type, config)
+                }
+            }
 
-    class MyPlugin implements Plugin<Project>, PluginUtils { Project project }
-    new MyPlugin()
-'''
+            class MyPlugin implements Plugin<Project>, PluginUtils { Project project }
+            new MyPlugin()
+        '''
     }
 
-    // GROOVY-7123
+    @Test // GROOVY-7123
     void testHelperSetterShouldNotReturnVoid() {
         assertScript '''
             trait A {
@@ -2171,94 +2288,99 @@ d.foo()
         '''
     }
 
-    static trait TestTrait {
-        int a() { 123 }
-    }
-
+    @Test
     void testSimpleSelfType() {
-        assertScript '''import groovy.transform.SelfType
-        import groovy.transform.CompileStatic
+        assertScript '''
+            import groovy.transform.SelfType
+            import groovy.transform.CompileStatic
 
-        trait A {
-            int a() { 1 }
-        }
+            trait A {
+                int a() { 1 }
+            }
 
-        @CompileStatic
-        @SelfType(A)
-        trait B {
-            int b() { 2*a() }
-        }
-        class C implements A,B {}
-        def c = new C()
-        assert c.b() == 2
+            @CompileStatic
+            @SelfType(A)
+            trait B {
+                int b() { 2*a() }
+            }
+            class C implements A,B {}
+            def c = new C()
+            assert c.b() == 2
         '''
     }
 
+    @Test
     void testSimpleSelfTypeInSubTrait() {
-        assertScript '''import groovy.transform.SelfType
-        import groovy.transform.CompileStatic
+        assertScript '''
+            import groovy.transform.SelfType
+            import groovy.transform.CompileStatic
 
-        trait A {
-            int a() { 1 }
-        }
+            trait A {
+                int a() { 1 }
+            }
 
-        @CompileStatic
-        @SelfType(A)
-        trait B {
-            int b() { 2*a() }
-        }
+            @CompileStatic
+            @SelfType(A)
+            trait B {
+                int b() { 2*a() }
+            }
 
-        @CompileStatic
-        trait SubB extends B {
-            int c() { 3*a() }
-        }
+            @CompileStatic
+            trait SubB extends B {
+                int c() { 3*a() }
+            }
 
 
-        class C implements A,SubB {}
-        def c = new C()
-        assert c.c() == 3
+            class C implements A,SubB {}
+            def c = new C()
+            assert c.c() == 3
         '''
     }
 
+    @Test
     void testDoubleSelfType() {
-        assertScript '''import groovy.transform.SelfType
-        import groovy.transform.CompileStatic
+        assertScript '''
+            import groovy.transform.SelfType
+            import groovy.transform.CompileStatic
 
-        trait A {
-            int a() { 1 }
-        }
-        trait A2 {
-            int a2() { 2 }
-        }
+            trait A {
+                int a() { 1 }
+            }
+            trait A2 {
+                int a2() { 2 }
+            }
 
-        @CompileStatic
-        @SelfType([A,A2])
-        trait B {
-            int b() { 2*a()*a2() }
-        }
-        class C implements A,A2,B {}
-        def c = new C()
-        assert c.b() == 4
+            @CompileStatic
+            @SelfType([A,A2])
+            trait B {
+                int b() { 2*a()*a2() }
+            }
+            class C implements A,A2,B {}
+            def c = new C()
+            assert c.b() == 4
         '''
     }
 
+    @Test
     void testClassDoesNotImplementSelfType() {
         def err = shouldFail '''
-        import groovy.transform.SelfType
-        import groovy.transform.CompileStatic
+            import groovy.transform.SelfType
+            import groovy.transform.CompileStatic
 
-        @CompileStatic
-        @SelfType([String,Serializable])
-        trait B {
-            String b() { toUpperCase() }
-        }
-        class C implements B {}
-        def c = new C()
+            @CompileStatic
+            @SelfType([String,Serializable])
+            trait B {
+                String b() { toUpperCase() }
+            }
+            class C implements B {}
+            def c = new C()
         '''
-        assert err.contains("class 'C' implements trait 'B' but does not extend self type class 'java.lang.String'")
-        assert err.contains("class 'C' implements trait 'B' but does not implement self type interface 'java.io.Serializable'")
+
+        assert err =~ "class 'C' implements trait 'B' but does not extend self type class 'java.lang.String'"
+        assert err =~ "class 'C' implements trait 'B' but does not implement self type interface 'java.io.Serializable'"
     }
 
+    @Test
     void testClassDoesNotImplementSelfTypeDefinedInInheritedTrait() {
         def err = shouldFail '''
             import groovy.transform.SelfType
@@ -2272,102 +2394,114 @@ d.foo()
             class Child implements Middle { }
             new Child().foo()
         '''
-        assert err.contains("class 'Child' implements trait 'Trait' but does not implement self type interface 'Self'")
+
+        assert err =~ "class 'Child' implements trait 'Trait' but does not implement self type interface 'Self'"
     }
 
+    @Test
     void testClassDoesNotImplementSelfTypeUsingAbstractClass() {
         def err = shouldFail '''
-        import groovy.transform.SelfType
-        import groovy.transform.CompileStatic
-
-        @CompileStatic
-        @SelfType([String,Serializable])
-        trait B {
-            String b() { toUpperCase() }
-        }
-        abstract class C implements B {}
-        class D extends C {}
-        def c = new D()
+            import groovy.transform.SelfType
+            import groovy.transform.CompileStatic
 
+            @CompileStatic
+            @SelfType([String,Serializable])
+            trait B {
+                String b() { toUpperCase() }
+            }
+            abstract class C implements B {}
+            class D extends C {}
+            def c = new D()
         '''
-        assert err.contains("class 'C' implements trait 'B' but does not extend self type class 'java.lang.String'")
-        assert err.contains("class 'C' implements trait 'B' but does not implement self type interface 'java.io.Serializable'")
+
+        assert err =~ "class 'C' implements trait 'B' but does not extend self type class 'java.lang.String'"
+        assert err =~ "class 'C' implements trait 'B' but does not implement self type interface 'java.io.Serializable'"
     }
 
+    @Test
     void testMethodAcceptingThisAsSelfTrait() {
         assertScript '''
-import groovy.transform.SelfType
-import groovy.transform.CompileStatic
+            import groovy.transform.SelfType
+            import groovy.transform.CompileStatic
 
-class CommunicationService {
-    static void sendMessage(String from, String to, String message) {
-        println "$from sent [$message] to $to"
-    }
-}
+            class CommunicationService {
+                static void sendMessage(String from, String to, String message) {
+                    println "$from sent [$message] to $to"
+                }
+            }
 
-class Device { String id }
+            class Device { String id }
 
-@SelfType(Device)
-@CompileStatic
-trait Communicating {
-    void sendMessage(Device to, String message) {
-        SecurityService.check(this)
-        CommunicationService.sendMessage(id, to.id, message)
-    }
-}
+            @SelfType(Device)
+            @CompileStatic
+            trait Communicating {
+                void sendMessage(Device to, String message) {
+                    SecurityService.check(this)
+                    CommunicationService.sendMessage(id, to.id, message)
+                }
+            }
 
-class MyDevice extends Device implements Communicating {}
+            class MyDevice extends Device implements Communicating {}
 
-def bob = new MyDevice(id:'Bob')
-def alice = new MyDevice(id:'Alice')
-bob.sendMessage(alice,'secret')
+            def bob = new MyDevice(id:'Bob')
+            def alice = new MyDevice(id:'Alice')
+            bob.sendMessage(alice,'secret')
 
-class SecurityService {
-    static void check(Device d) { if (d.id==null) throw new SecurityException() }
-}
-'''
+            class SecurityService {
+                static void check(Device d) { if (d.id==null) throw new SecurityException() }
+            }
+        '''
     }
 
+    @Test
     void testRuntimeSelfType() {
-        assertScript '''import groovy.transform.CompileStatic
-import groovy.transform.SelfType
+        assertScript '''
+            import groovy.transform.CompileStatic
+            import groovy.transform.SelfType
 
-trait A {
-    int a() { 1 }
-}
+            trait A {
+                int a() { 1 }
+            }
 
-@CompileStatic
-@SelfType(A)
-trait B {
-    int b() { 2*a() }
-}
-class C implements A {}
-def c = new C() as B
-assert c.b() == 2
-'''
+            @CompileStatic
+            @SelfType(A)
+            trait B {
+                int b() { 2*a() }
+            }
+            class C implements A {}
+            def c = new C() as B
+            assert c.b() == 2
+        '''
     }
 
+    @Test
     void testRuntimeSelfTypeWithInheritance() {
-        assertScript '''import groovy.transform.CompileStatic
-import groovy.transform.SelfType
+        assertScript '''
+            import groovy.transform.CompileStatic
+            import groovy.transform.SelfType
 
-trait A {
-    int a() { 1 }
-}
+            trait A {
+                int a() { 1 }
+            }
 
-@CompileStatic
-@SelfType(A)
-trait B {
-    int b() { 2*a() }
-}
+            @CompileStatic
+            @SelfType(A)
+            trait B {
+                int b() { 2*a() }
+            }
 
-trait B2 extends B {}
+            trait B2 extends B {}
 
-class C implements A {}
-def c = new C() as B2
-assert c.b() == 2
-'''
+            class C implements A {}
+            def c = new C() as B2
+            assert c.b() == 2
+        '''
     }
+
+    @SelfType([String, Date])
+    trait DoubleSelfTypeTrait {}
+
+    @Test
     void testAnnotationsOfPrecompiledTrait() {
         def cn = ClassHelper.make(DoubleSelfTypeTrait)
         def ann = cn.getAnnotations(ClassHelper.make(SelfType))
@@ -2380,12 +2514,8 @@ assert c.b() == 2
         }
     }
 
-
-    @SelfType([String, Date])
-    trait DoubleSelfTypeTrait {}
-
-    //GROOVY-7287
-    void testTraitWithMethodLevelGenericsShadowing() {
+    @Test // GROOVY-7287
+    void testTraitWithMethodLevelGenericsShadowing1() {
         assertScript '''
             trait Configurable<ConfigObject> {
                 ConfigObject configObject
@@ -2429,22 +2559,26 @@ assert c.b() == 2
             }
             assert module.value == 'test-1.0'
         '''
+    }
 
+    @Test // GROOVY-7287
+    void testTraitWithMethodLevelGenericsShadowing2() {
         assertScript '''
             trait SomeTrait {
                 def <T extends Number> T someOtherMethod() {}
             }
             class SuperClass<T> implements SomeTrait {}
             class SubClass extends SuperClass<String> implements SomeTrait {}
-            SubClass.declaredMethods.findAll    {it.name=="someOtherMethod"}.
-                                     each {
-                                         assert it.returnType == Number
-                                         assert it.genericReturnType.name == "T"
-                                     }
+
+            SubClass.declaredMethods.findAll { it.name == 'someOtherMethod' }
+                                    .each {
+                                        assert it.returnType == Number
+                                        assert it.genericReturnType.name == 'T'
+                                    }
         '''
     }
 
-    //GROOVY-7297
+    @Test // GROOVY-7297
     void testMethodlevelGenericsFromPrecompiledClass() {
         //SomeTrait needs to be outside the script
         assertScript '''
@@ -2459,7 +2593,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8281
+    @Test // GROOVY-8281
     void testFinalFieldsDependency() {
         assertScript '''
             trait MyTrait {
@@ -2474,7 +2608,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8282
+    @Test // GROOVY-8282
     void testBareNamedArgumentPrivateMethodCall() {
         assertScript '''
             trait BugReproduction {
@@ -2492,7 +2626,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8730
+    @Test // GROOVY-8730
     void testAbstractMethodsNotNeededInHelperClass() {
         assertScript '''
             import static groovy.test.GroovyAssert.shouldFail
@@ -2511,7 +2645,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8731
+    @Test // GROOVY-8731
     void testStaticMethodsIgnoredWhenExistingInstanceMethodsFound() {
         assertScript '''
             trait StaticFooBarBaz {
@@ -2536,7 +2670,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-6716
+    @Test // GROOVY-6716
     void testAnonymousInnerClassStyleTraitUsage() {
         assertScript '''
             interface Foo { def foo() }
@@ -2553,7 +2687,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8722
+    @Test // GROOVY-8722
     void testFinalModifierSupport() {
         assertScript '''
             import static java.lang.reflect.Modifier.isFinal
@@ -2591,6 +2725,7 @@ assert c.b() == 2
                 assert !isFinal(FooFoo2, 'baz')
             }
         '''
+
         assertScript '''
             trait Startable {
                 final int start() { doStart() * 2 }
@@ -2607,7 +2742,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8880
+    @Test // GROOVY-8880
     void testTraitWithInitBlock() {
         assertScript '''
             trait MyTrait {
@@ -2627,7 +2762,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8880
+    @Test // GROOVY-8880
     void testTraitWithStaticInitBlock() {
         assertScript '''
             trait MyTrait {
@@ -2645,7 +2780,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8892
+    @Test // GROOVY-8892
     void testTraitWithStaticInitBlockWithAndWithoutProps() {
         assertScript '''
             class Counter {
@@ -2669,7 +2804,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8954
+    @Test // GROOVY-8954
     void testTraitWithPropertyAlsoFromInterfaceSC() {
         assertScript '''
             interface DomainProp {
@@ -2689,7 +2824,7 @@ assert c.b() == 2
         '''
     }
 
-    //GROOVY-8272
+    @Test // GROOVY-8272
     void testTraitAccessToInheritedStaticMethods() {
         assertScript '''
             import groovy.transform.CompileStatic


[groovy] 02/04: Added missing package statements (or qualifiers)

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 088888cad05565c30cc4a804b6ae121cb624963f
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Mon Aug 12 11:12:49 2019 -0500

    Added missing package statements (or qualifiers)
---
 src/test/{groovy => }/NoPackageTest.groovy         |  4 ++-
 src/test/gls/annotations/AnnotationTest.groovy     |  4 ++-
 src/test/gls/annotations/Base3278.groovy           |  2 ++
 src/test/gls/annotations/Child2.groovy             |  2 ++
 src/test/gls/annotations/ConstAnnotation.groovy    |  2 ++
 .../gls/invocation/ClassDuplicationTest.groovy     |  6 ++--
 src/test/groovy/BinaryStreamsTest.groovy           |  4 ++-
 src/test/groovy/benchmarks/createLoop.groovy       |  5 +--
 src/test/groovy/benchmarks/loop.groovy             |  3 +-
 src/test/groovy/benchmarks/loop2.groovy            |  2 --
 .../bugs/Groovy1759.groovy}                        | 32 ++++++++++++++----
 src/test/groovy/bugs/Groovy1759_Bug.groovy         | 39 ----------------------
 .../{Groovy2951Bug.groovy => Groovy2951.groovy}    | 16 ++++++---
 .../{Groovy3406Test.groovy => Groovy3406.groovy}   | 14 +++++---
 .../groovy/lang/gcldeadlock/DeadlockBugUtil.groovy |  4 ++-
 src/test/groovy/lang/gcldeadlock/script1.groovy    |  2 +-
 src/test/indy/IndyUsageTest.groovy                 | 34 +++++++++++--------
 .../groovy/ast/LazyInitOnClassNodeTest.groovy      | 11 +++---
 .../groovy/runtime/memoize/NullValueTest.groovy    | 23 ++++++++++---
 .../util/AbstractConcurrentMapSegmentTest.groovy   |  8 ++---
 20 files changed, 125 insertions(+), 92 deletions(-)

diff --git a/src/test/groovy/NoPackageTest.groovy b/src/test/NoPackageTest.groovy
similarity index 93%
rename from src/test/groovy/NoPackageTest.groovy
rename to src/test/NoPackageTest.groovy
index a9ae258..c37ddad 100644
--- a/src/test/groovy/NoPackageTest.groovy
+++ b/src/test/NoPackageTest.groovy
@@ -16,8 +16,10 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-class NoPackageTest extends GroovyTestCase {
+import org.junit.Test
 
+final class NoPackageTest {
+    @Test
     void testClassDef() {
         assert getClass().name == "NoPackageTest"
     }
diff --git a/src/test/gls/annotations/AnnotationTest.groovy b/src/test/gls/annotations/AnnotationTest.groovy
index 01a4c50..bd58bb0 100644
--- a/src/test/gls/annotations/AnnotationTest.groovy
+++ b/src/test/gls/annotations/AnnotationTest.groovy
@@ -23,7 +23,7 @@ import gls.CompilableTestSupport
 /**
  * Tests various properties of annotation definitions.
  */
-class AnnotationTest extends CompilableTestSupport {
+final class AnnotationTest extends CompilableTestSupport {
 
     /**
      * Check that it is possible to annotate an annotation definition with field and method target elements.
@@ -827,6 +827,8 @@ class AnnotationTest extends CompilableTestSupport {
     void testAnnotationAttributeConstantFromPrecompiledGroovyClass() {
         // GROOVY-3278
         assertScript '''
+            import gls.annotations.*
+
             @ConstAnnotation(ints = 42)
             class Child1 extends Base3278 {}
             
diff --git a/src/test/gls/annotations/Base3278.groovy b/src/test/gls/annotations/Base3278.groovy
index a3ecd3b..984229c 100644
--- a/src/test/gls/annotations/Base3278.groovy
+++ b/src/test/gls/annotations/Base3278.groovy
@@ -16,6 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package gls.annotations
+
 class Base3278 {
     static final int CONST = 3278
     static final int CONST1 = 1024 * 2
diff --git a/src/test/gls/annotations/Child2.groovy b/src/test/gls/annotations/Child2.groovy
index afa762d..1934116 100644
--- a/src/test/gls/annotations/Child2.groovy
+++ b/src/test/gls/annotations/Child2.groovy
@@ -16,5 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package gls.annotations
+
 @ConstAnnotation(ints = Integer.MAX_VALUE)
 class Child2 extends Base3278 {}
diff --git a/src/test/gls/annotations/ConstAnnotation.groovy b/src/test/gls/annotations/ConstAnnotation.groovy
index e1e780f..4b2b8fd 100644
--- a/src/test/gls/annotations/ConstAnnotation.groovy
+++ b/src/test/gls/annotations/ConstAnnotation.groovy
@@ -16,6 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package gls.annotations
+
 import java.lang.annotation.*
 
 @Retention(RetentionPolicy.RUNTIME)
diff --git a/src/test/gls/invocation/ClassDuplicationTest.groovy b/src/test/gls/invocation/ClassDuplicationTest.groovy
index 9d240f8..38c8c63 100644
--- a/src/test/gls/invocation/ClassDuplicationTest.groovy
+++ b/src/test/gls/invocation/ClassDuplicationTest.groovy
@@ -16,7 +16,9 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-class ClassDuplicationTest extends GroovyTestCase {
+package gls.invocation
+
+final class ClassDuplicationTest extends GroovyTestCase {
     void testDuplicationOnMethodSignatureTest() {
         def shell1 = new GroovyShell(this.class.classLoader)
         def obj1 = shell1.evaluate("""
@@ -34,6 +36,6 @@ class ClassDuplicationTest extends GroovyTestCase {
             assert false
         } catch (MissingMethodException mme) {
             assert mme.toString().contains("A (defined by")
-        }     
+        }
     }
 }
diff --git a/src/test/groovy/BinaryStreamsTest.groovy b/src/test/groovy/BinaryStreamsTest.groovy
index d208175..8c9e610 100755
--- a/src/test/groovy/BinaryStreamsTest.groovy
+++ b/src/test/groovy/BinaryStreamsTest.groovy
@@ -16,10 +16,12 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package groovy
+
 /**
  * Test case for DefaultGroovyMethods involving Object streams and data streams.
  */
-class BinaryStreamsTest extends GroovyTestCase {
+final class BinaryStreamsTest extends GroovyTestCase {
 
     void testNewObjectStream() {
         def temp1 = tempFile
diff --git a/src/test/groovy/benchmarks/createLoop.groovy b/src/test/groovy/benchmarks/createLoop.groovy
index fc7610c..35bb027 100644
--- a/src/test/groovy/benchmarks/createLoop.groovy
+++ b/src/test/groovy/benchmarks/createLoop.groovy
@@ -16,10 +16,11 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package groovy.benchmarks
+
 c = {
-  for (i in 1..it){
+  for (i in 1..it) {
     x = new Object()
   }
 }
 c.call(30000)
-
diff --git a/src/test/groovy/benchmarks/loop.groovy b/src/test/groovy/benchmarks/loop.groovy
index c1438de..996c3e4 100644
--- a/src/test/groovy/benchmarks/loop.groovy
+++ b/src/test/groovy/benchmarks/loop.groovy
@@ -19,7 +19,7 @@
 package groovy.benchmarks
 
 class Loop {
-  def array = new ArrayList()
+  def array = []
   def pos = 0
 
   void push(obj){
@@ -41,4 +41,3 @@ class Loop {
      }
   }
 }
-
diff --git a/src/test/groovy/benchmarks/loop2.groovy b/src/test/groovy/benchmarks/loop2.groovy
index 4d178d8..fb304b3 100644
--- a/src/test/groovy/benchmarks/loop2.groovy
+++ b/src/test/groovy/benchmarks/loop2.groovy
@@ -34,7 +34,6 @@ class Loop2 {
 
   static void main(args){
      println "Starting the Loop2 test"
-      
      def s = new Loop2()
      for (i in 1..1000000){
        s.push(i)
@@ -44,4 +43,3 @@ class Loop2 {
      }
   }
 }
-
diff --git a/src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy b/src/test/groovy/bugs/Groovy1759.groovy
similarity index 55%
copy from src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy
copy to src/test/groovy/bugs/Groovy1759.groovy
index 340c5fa..4752d35 100644
--- a/src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy
+++ b/src/test/groovy/bugs/Groovy1759.groovy
@@ -16,14 +16,34 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-package org.codehaus.groovy.runtime.memoize
+package groovy.bugs
 
-class NullValueTest extends GroovyTestCase {
-    void testEquals() throws Exception {
-        assert new Memoize.MemoizeNullValue() == new Memoize.MemoizeNullValue()
+import org.junit.Test
+
+final class Groovy1759 {
+
+    @Test
+    void testInterception() {
+        def benchmarkInterceptor = new BenchmarkInterceptor()
+        def proxy = ProxyMetaClass.getInstance(A.class)
+        proxy.setInterceptor(benchmarkInterceptor)
+        proxy.use {
+            def a = new A()
+            a.a()
+            a.b()
+        }
+
+        def actual = benchmarkInterceptor.statistic().collect { [it[0], it[1]] }
+        def expected = [
+            ['ctor', 1],
+            ['a', 1],
+            ['b', 2]
+        ]
+        assert expected == actual
     }
 
-    void testHashCode() throws Exception {
-        assert new Memoize.MemoizeNullValue().hashCode() == new Memoize.MemoizeNullValue().hashCode()
+    static class A {
+        void a() { b() }
+        void b() {     }
     }
 }
diff --git a/src/test/groovy/bugs/Groovy1759_Bug.groovy b/src/test/groovy/bugs/Groovy1759_Bug.groovy
deleted file mode 100644
index 3b146b0..0000000
--- a/src/test/groovy/bugs/Groovy1759_Bug.groovy
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  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.
- */
-class Groovy1759_Bug extends GroovyTestCase {
-   void testInterception() {
-      def benchmarkInterceptor = new BenchmarkInterceptor()
-      def proxy = ProxyMetaClass.getInstance(A.class)
-      proxy.setInterceptor(benchmarkInterceptor)
-      proxy.use {
-         def a = new A()
-         a.a()
-         a.b()
-      }
-      
-      def actual = benchmarkInterceptor.statistic().collect{ [ it[0], it[1] ] }
-      def expected = [['ctor', 1],['a', 1],['b', 2]]
-      assert expected == actual
-   }
-}
-
-class A{
-   void a(){ b() }
-   void b(){}
-}
diff --git a/src/test/groovy/bugs/Groovy2951Bug.groovy b/src/test/groovy/bugs/Groovy2951.groovy
similarity index 84%
rename from src/test/groovy/bugs/Groovy2951Bug.groovy
rename to src/test/groovy/bugs/Groovy2951.groovy
index 9c851d1..20b142d 100644
--- a/src/test/groovy/bugs/Groovy2951Bug.groovy
+++ b/src/test/groovy/bugs/Groovy2951.groovy
@@ -16,8 +16,14 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-class Groovy2951Bug extends GroovyTestCase{
-    def void testInstanceLevelMissingMethodWithRegularClosure1() {
+package groovy.bugs
+
+import org.junit.Test
+
+final class Groovy2951 {
+
+    @Test
+    void testInstanceLevelMissingMethodWithRegularClosure1() {
         Groovy2951BugClass1.metaClass.methodMissing = {
             method, args ->
             return method
@@ -26,7 +32,8 @@ class Groovy2951Bug extends GroovyTestCase{
         assert result == "test1"
     }
 
-    def void testInstanceLevelMissingMethodWithRegularClosure2() {
+    @Test
+    void testInstanceLevelMissingMethodWithRegularClosure2() {
         Groovy2951BugClass2.metaClass.methodMissing << { method, args ->
             return method
         }
@@ -34,7 +41,8 @@ class Groovy2951Bug extends GroovyTestCase{
         assert result == "test2"
     }
 
-    def void testInstanceLevelMissingMethodWithMethodClosure() {
+    @Test
+    void testInstanceLevelMissingMethodWithMethodClosure() {
         Groovy2951BugClass3.metaClass.methodMissing = Groovy2951BugClass3.&mm
 
         def result = new Groovy2951BugClass3().test3("arg3", "arg4")
diff --git a/src/test/groovy/lang/Groovy3406Test.groovy b/src/test/groovy/lang/Groovy3406.groovy
similarity index 90%
rename from src/test/groovy/lang/Groovy3406Test.groovy
rename to src/test/groovy/lang/Groovy3406.groovy
index 42b9d05..b7dd347 100644
--- a/src/test/groovy/lang/Groovy3406Test.groovy
+++ b/src/test/groovy/lang/Groovy3406.groovy
@@ -16,12 +16,18 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-class Groovy3406Test extends GroovyTestCase {
-    void testBug() {    
+package groovy.lang
+
+import org.junit.Test
+
+final class Groovy3406 {
+
+    @Test
+    void testBug() {
         def str = 'hello'
         def methodName = 'toUpperCase'
-        
         def methodOfInterest = str.metaClass.getMetaMethod(methodName)
+
         assert methodOfInterest.invoke(str) == "HELLO"
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/groovy/lang/gcldeadlock/DeadlockBugUtil.groovy b/src/test/groovy/lang/gcldeadlock/DeadlockBugUtil.groovy
index 0b5df76..23cf979 100644
--- a/src/test/groovy/lang/gcldeadlock/DeadlockBugUtil.groovy
+++ b/src/test/groovy/lang/gcldeadlock/DeadlockBugUtil.groovy
@@ -16,6 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package groovy.lang.gcldeadlock
+
 class DeadlockBugUtil {
-  def plus(a, b){ return a + b }
+    def plus(a, b) { return a + b }
 }
diff --git a/src/test/groovy/lang/gcldeadlock/script1.groovy b/src/test/groovy/lang/gcldeadlock/script1.groovy
index bfa6664..5545e50 100644
--- a/src/test/groovy/lang/gcldeadlock/script1.groovy
+++ b/src/test/groovy/lang/gcldeadlock/script1.groovy
@@ -16,6 +16,6 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-def util = new DeadlockBugUtil()
+def util = new groovy.lang.gcldeadlock.DeadlockBugUtil()
 
 number + "+" + number + "=" + util.plus(number, number)
diff --git a/src/test/indy/IndyUsageTest.groovy b/src/test/indy/IndyUsageTest.groovy
index a63e075..436fb1c 100644
--- a/src/test/indy/IndyUsageTest.groovy
+++ b/src/test/indy/IndyUsageTest.groovy
@@ -16,17 +16,25 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-class IndyUsageTest extends GroovyTestCase {
-  void testIndyIsUsedNested() {
-    assertScript """
-      def foo(){
-         throw new Exception("blah")
-      }
-      try {
-        foo()
-      } catch (Exception e) {
-        assert e.stackTrace.find { it.className == "org.codehaus.groovy.vmplugin.v7.IndyInterface" }
-      }
-    """
-  }
+package indy
+
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class IndyUsageTest {
+
+    @Test
+    void testIndyIsUsedNested() {
+        assertScript '''
+            def foo() {
+                 throw new Exception('blah')
+            }
+            try {
+                foo()
+            } catch (e) {
+                assert e.stackTrace.find { it.className == 'org.codehaus.groovy.vmplugin.v7.IndyInterface' }
+            }
+        '''
+    }
 }
diff --git a/src/test/org/codehaus/groovy/ast/LazyInitOnClassNodeTest.groovy b/src/test/org/codehaus/groovy/ast/LazyInitOnClassNodeTest.groovy
index c44d35a..4ba3bf8 100644
--- a/src/test/org/codehaus/groovy/ast/LazyInitOnClassNodeTest.groovy
+++ b/src/test/org/codehaus/groovy/ast/LazyInitOnClassNodeTest.groovy
@@ -16,6 +16,8 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package org.codehaus.groovy.ast
+
 import org.codehaus.groovy.ast.*
 
 class LazyInitOnClassNodeTest extends GroovyTestCase {
@@ -24,13 +26,13 @@ class LazyInitOnClassNodeTest extends GroovyTestCase {
           class ClassNodeMethodsListGrowth {
             // Setting the type to ArrayList triggers a growth in methodsList
             ArrayList array1=new ArrayList()
-        
+
             // ... using dynamic typing does not
             // def array2=new ArrayList()
-            
+
             // Test method as a sanity check
             def get(o) { return "ok" }
-          } 
+          }
         """
         def listType = ClassHelper.make(List.class)
         def last=0
@@ -38,9 +40,8 @@ class LazyInitOnClassNodeTest extends GroovyTestCase {
           def loader = new GroovyClassLoader(this.class.classLoader)
           assert loader.parseClass(script).newInstance().get("default")=="ok"
           def size = listType.redirect().getMethods().size()
-          if (last!=0) assert last==size 
+          if (last!=0) assert last==size
           if (last==0) last = size
         }
     }
 }
-
diff --git a/src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy b/src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy
index 340c5fa..1995d22 100644
--- a/src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/memoize/NullValueTest.groovy
@@ -18,12 +18,27 @@
  */
 package org.codehaus.groovy.runtime.memoize
 
-class NullValueTest extends GroovyTestCase {
-    void testEquals() throws Exception {
-        assert new Memoize.MemoizeNullValue() == new Memoize.MemoizeNullValue()
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class NullValueTest {
+
+    @Test
+    void testEquals() {
+        assertScript '''
+            def one = new org.codehaus.groovy.runtime.memoize.Memoize.MemoizeNullValue()
+            def two = new org.codehaus.groovy.runtime.memoize.Memoize.MemoizeNullValue()
+            assert one.equals(two)
+        '''
     }
 
+    @Test
     void testHashCode() throws Exception {
-        assert new Memoize.MemoizeNullValue().hashCode() == new Memoize.MemoizeNullValue().hashCode()
+        assertScript '''
+            def one = new org.codehaus.groovy.runtime.memoize.Memoize.MemoizeNullValue()
+            def two = new org.codehaus.groovy.runtime.memoize.Memoize.MemoizeNullValue()
+            assert one.hashCode() == two.hashCode()
+        '''
     }
 }
diff --git a/src/test/org/codehaus/groovy/util/AbstractConcurrentMapSegmentTest.groovy b/src/test/org/codehaus/groovy/util/AbstractConcurrentMapSegmentTest.groovy
index 9b8c729..4f275f5 100644
--- a/src/test/org/codehaus/groovy/util/AbstractConcurrentMapSegmentTest.groovy
+++ b/src/test/org/codehaus/groovy/util/AbstractConcurrentMapSegmentTest.groovy
@@ -129,14 +129,14 @@ class AbstractConcurrentMapSegmentTest {
         assert segment.table.length > INITIAL_SEGMENT_SIZE == truth
     }
 
-    class TestSegment extends AbstractConcurrentMap.Segment {
+    class TestSegment extends org.codehaus.groovy.util.AbstractConcurrentMap.Segment {
 
         protected TestSegment(int initialCapacity) {
             super(initialCapacity)
         }
 
         @Override
-        protected AbstractConcurrentMap.Entry createEntry(Object key, int hash, Object value) {
+        protected org.codehaus.groovy.util.AbstractConcurrentMap.Entry createEntry(Object key, int hash, Object value) {
             TestEntry entry = new TestEntry(key, hash, value)
             entries.add(entry)
             return entry
@@ -150,7 +150,7 @@ class AbstractConcurrentMapSegmentTest {
     }
 }
 
-class TestEntry implements AbstractConcurrentMap.Entry {
+class TestEntry implements org.codehaus.groovy.util.AbstractConcurrentMap.Entry {
     Object key
     Object value
     int hash
@@ -190,4 +190,4 @@ class TestEntry implements AbstractConcurrentMap.Entry {
     public void setValid(boolean valid) {
         this.valid = valid
     }
-}
\ No newline at end of file
+}