groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch GROOVY_2_5_X updated: minor refactor: reduce some codenarc warnings
Date Wed, 24 Apr 2019 00:57:44 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
     new 1875cf3  minor refactor: reduce some codenarc warnings
1875cf3 is described below

commit 1875cf37bac2b453322b27ec4aef17bf055fbebe
Author: Paul King <paulk@asert.com.au>
AuthorDate: Wed Apr 24 07:45:03 2019 +1000

    minor refactor: reduce some codenarc warnings
---
 src/test/gls/annotations/AnnotationTest.groovy     |  2 +-
 src/test/gls/enums/EnumTest.groovy                 | 15 +++---
 src/test/gls/generics/GenericsTest.groovy          | 30 ++++++------
 src/test/gls/innerClass/InnerClassTest.groovy      |  2 +-
 src/test/gls/innerClass/InnerInterfaceTest.groovy  | 22 ++++-----
 .../gls/invocation/ClosureDelegationTest.groovy    | 10 ++--
 .../invocation/ConstructorDelegationTest.groovy    | 14 +++---
 src/test/gls/invocation/CovariantReturnTest.groovy |  2 +-
 src/test/gls/invocation/MethodSelectionTest.groovy |  6 +--
 .../invocation/StaticMethodInvocationTest.groovy   |  2 +-
 .../gls/property/MetaClassOverridingTest.groovy    |  2 +-
 src/test/gls/scope/BlockScopeVisibilityTest.groovy |  8 ++--
 src/test/gls/scope/ClassVariableHidingTest.groovy  | 32 ++++++-------
 .../MultipleDefinitionOfSameVariableTest.groovy    | 14 +++---
 src/test/gls/scope/NameResolvingTest.groovy        | 14 +++---
 src/test/gls/scope/StaticScopeTest.groovy          | 30 ++++++------
 src/test/gls/statements/DeclarationTest.groovy     | 53 +++++++++++-----------
 src/test/gls/statements/ReturnTest.groovy          |  8 ++--
 src/test/gls/syntax/AssertTest.groovy              |  2 +-
 .../gls/syntax/MethodCallValidationTest.groovy     |  2 +-
 src/test/gls/syntax/NumberLiteralTest.groovy       |  4 +-
 .../gls/syntax/OldClosureSyntaxRemovalTest.groovy  | 46 ++++++++++---------
 .../gls/syntax/OldPropertySyntaxRemovalTest.groovy | 20 ++++----
 src/test/gls/syntax/OldSpreadTest.groovy           | 18 ++++----
 src/test/gls/syntax/ParsingTest.groovy             |  4 +-
 .../types/BooleanExpressionConversionTest.groovy   |  4 +-
 src/test/gls/types/GroovyCastTest.groovy           |  4 +-
 src/test/gls/types/OperationsResultTypeTest.groovy | 50 ++++++++++----------
 28 files changed, 216 insertions(+), 204 deletions(-)

diff --git a/src/test/gls/annotations/AnnotationTest.groovy b/src/test/gls/annotations/AnnotationTest.groovy
index 64f294e..d5a5ea6 100644
--- a/src/test/gls/annotations/AnnotationTest.groovy
+++ b/src/test/gls/annotations/AnnotationTest.groovy
@@ -692,7 +692,7 @@ class AnnotationTest extends CompilableTestSupport {
 
             class Foo {
               @NonNull public Integer foo
-              @NonNull public Integer bar(@NonNull String baz) {}
+              @NonNull Integer bar(@NonNull String baz) {}
             }
 
             def expected = '@NonNull()'
diff --git a/src/test/gls/enums/EnumTest.groovy b/src/test/gls/enums/EnumTest.groovy
index 4f538d2..0e72f0f 100644
--- a/src/test/gls/enums/EnumTest.groovy
+++ b/src/test/gls/enums/EnumTest.groovy
@@ -121,7 +121,7 @@ class EnumTest extends CompilableTestSupport {
                 ONE([111, 222])
                 ListEnum1(Object listArg){
                     assert listArg == [111, 222]
-                    assert listArg instanceof java.util.ArrayList
+                    assert listArg instanceof ArrayList
                 }
             }
             println ListEnum1.ONE
@@ -133,23 +133,22 @@ class EnumTest extends CompilableTestSupport {
                 TWO([234, [567,12]])
                 ListEnum2(Object listArg){
                     assert listArg == [234, [567, 12]]
-                    assert listArg instanceof java.util.ArrayList
+                    assert listArg instanceof ArrayList
                 }
             }
             println ListEnum2.TWO
         """
-        sh.evaluate(enumStr);
+        sh.evaluate(enumStr)
     }
     
     void testSingleListDoesNoInfluenceMaps() {
         // the fix for GROOVY-2933 caused map["taku"]
         // to become map[(["take])] instead. -> GROOVY-3214
         assertScript """
-            public enum FontFamily {
+            enum FontFamily {
                 ARIAL
             
-                static public void obtainMyMap()
-                {
+                static void obtainMyMap() {
                     Map map = [:]
                     map["taku"] = "dio"
                     assert map.taku == "dio"
@@ -180,7 +179,7 @@ class EnumTest extends CompilableTestSupport {
     }
 
     // the fix for GROOVY-3161
-    def void testStaticEnumFieldWithEnumValues() {
+    void testStaticEnumFieldWithEnumValues() {
         def allColors = GroovyColors3161.ALL_COLORS
         assert allColors.size() == 3
         assert allColors[0] == GroovyColors3161.red
@@ -189,7 +188,7 @@ class EnumTest extends CompilableTestSupport {
     }
 
     // the fix for GROOVY-3283
-    def void testImportStaticMoreThanOneEnum() {
+    void testImportStaticMoreThanOneEnum() {
         assertScript """
             enum Foo3283 { A,B }
             enum Bar3283 { X,Y }
diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy
index b547ed9..ae4258f 100644
--- a/src/test/gls/generics/GenericsTest.groovy
+++ b/src/test/gls/generics/GenericsTest.groovy
@@ -194,9 +194,9 @@ class GenericsTest extends GenericsTestBase {
 
     void testParameterAsParameterForReturnTypeAndFieldClass() {
         createClassInfo """
-               public class B<T> {
+               class B<T> {
                    private T owner;
-                   public Class<T> getOwnerClass(){}
+                   Class<T> getOwnerClass(){}
    
             } 
         """
@@ -277,7 +277,7 @@ class GenericsTest extends GenericsTestBase {
         import java.util.concurrent.*
 
         class CallableTask implements Callable<String> {
-          public String call() { "x" }
+            String call() { "x" }
         } 
         
         def task = new CallableTask()
@@ -292,7 +292,7 @@ class GenericsTest extends GenericsTestBase {
         abstract class AbstractCallableTask<T> implements Callable<T> { }
         abstract class SubclassCallableTask<T> extends AbstractCallableTask<T>
{ }
         class CallableTask extends SubclassCallableTask<String> {
-          public String call() { return "x"; }
+            String call() { return "x"; }
         }
         assert "x" == new CallableTask().call();
       """
@@ -335,23 +335,21 @@ class GenericsTest extends GenericsTestBase {
         assertScript """
 import java.util.concurrent.atomic.AtomicInteger
 
- public class ThreadId
- {
-  private static final AtomicInteger nextId = new AtomicInteger(0)
-  private static final ThreadLocal<Integer> threadId = [
-                  initialValue: { return nextId.getAndIncrement() }
-                  ] as ThreadLocal<Integer>
+class ThreadId {
+    private static final AtomicInteger nextId = new AtomicInteger(0)
+    private static final ThreadLocal<Integer> threadId = [
+        initialValue: { return nextId.getAndIncrement() }
+    ] as ThreadLocal<Integer>
 
-  public static int get()
-  {
-      System.out.println( "Thread ID: " + threadId.get());
-      return threadId.get();
-  }
+    static int get() {
+        println "Thread ID: " + threadId.get()
+        return threadId.get()
+    }
 
  }
  // we do not actually want to execute something, just
  // ensure this compiles, so we do a dummy command here
- assert ThreadId!=null
+ assert ThreadId != null
        """
     }
 
diff --git a/src/test/gls/innerClass/InnerClassTest.groovy b/src/test/gls/innerClass/InnerClassTest.groovy
index 9a0d6ad..6889192 100644
--- a/src/test/gls/innerClass/InnerClassTest.groovy
+++ b/src/test/gls/innerClass/InnerClassTest.groovy
@@ -570,7 +570,7 @@ import org.codehaus.groovy.classgen.Verifier
                     if (variables[field.name]) {
                         AccessController.doPrivileged(new PrivilegedAction() {
                             @Override
-                            public Object run() {
+                            Object run() {
                                 boolean wasAccessible = field.isAccessible()
                                 try {
                                     field.accessible = true
diff --git a/src/test/gls/innerClass/InnerInterfaceTest.groovy b/src/test/gls/innerClass/InnerInterfaceTest.groovy
index 41d407a..4ac2001 100644
--- a/src/test/gls/innerClass/InnerInterfaceTest.groovy
+++ b/src/test/gls/innerClass/InnerInterfaceTest.groovy
@@ -25,11 +25,11 @@ class InnerInterfaceTest extends GroovyTestCase {
 
     void testStaticInnerInterfaceInAClass() {
         assertScript """
-            public class Foo4422V1 {
-                static public class Bar {
+            class Foo4422V1 {
+                static class Bar {
                     def bar(){}
                 }
-                static public interface Baz {
+                static interface Baz {
                     String TEST = ""
                     def baz()
                 }
@@ -49,8 +49,8 @@ class InnerInterfaceTest extends GroovyTestCase {
 
     void testStaticInnerInterfaceInAnInterface() {
         assertScript """
-            public interface Foo4422V2 {
-                static public interface Baz {}
+            interface Foo4422V2 {
+                static interface Baz {}
             }
             
             assert Foo4422V2.Baz != null
@@ -59,9 +59,9 @@ class InnerInterfaceTest extends GroovyTestCase {
     
     void testNonStaticInnerInterfaceInAClass() {
         assertScript """
-            public class Foo4422V3 {
-                public class Bar {}
-                public interface Baz {}
+            class Foo4422V3 {
+                class Bar {}
+                interface Baz {}
             }
             
             assert Foo4422V3.Bar != null
@@ -88,14 +88,12 @@ class InnerInterfaceTest extends GroovyTestCase {
     void testResolveInnerInterface() {
         assertScript '''
             class Usage implements Koo {
-              static class MyInner extends Inner {}
+                static class MyInner extends Inner {}
             }
 
-            public interface Koo {
-
+            interface Koo {
                 class Inner {
                 }
-
             }
             Koo.Inner
         '''
diff --git a/src/test/gls/invocation/ClosureDelegationTest.groovy b/src/test/gls/invocation/ClosureDelegationTest.groovy
index 66398b3..44ae109 100644
--- a/src/test/gls/invocation/ClosureDelegationTest.groovy
+++ b/src/test/gls/invocation/ClosureDelegationTest.groovy
@@ -20,9 +20,9 @@ package gls.invocation
 
 import gls.CompilableTestSupport
 
-public class ClosureDelegationTest extends CompilableTestSupport {
+class ClosureDelegationTest extends CompilableTestSupport {
 
-    public void testMissingMethodMissingMethod() {
+    void testMissingMethodMissingMethod() {
       assertScript """
 class A {
   def methodMissing(String name, args) {
@@ -43,7 +43,7 @@ assert visited==true
         """
     }
 
-    public void testInvokeMethodMissingMethod() {
+    void testInvokeMethodMissingMethod() {
       assertScript """
 class A {
   def invokeMethod(String name, args) {
@@ -64,7 +64,7 @@ assert visited==true
         """
     }
     
-    public void testMissingMethodInvokeMethod() {
+    void testMissingMethodInvokeMethod() {
       assertScript """
 class A {
   def methodMissing(String name, args) {
@@ -85,7 +85,7 @@ assert visited==true
         """
     }
     
-    public void testInvokeMethodInvokeMethod() {
+    void testInvokeMethodInvokeMethod() {
       assertScript """
 class A {
   def invokeMethod(String name, args) {
diff --git a/src/test/gls/invocation/ConstructorDelegationTest.groovy b/src/test/gls/invocation/ConstructorDelegationTest.groovy
index 23aad37..210c595 100644
--- a/src/test/gls/invocation/ConstructorDelegationTest.groovy
+++ b/src/test/gls/invocation/ConstructorDelegationTest.groovy
@@ -20,9 +20,9 @@ package gls.invocation
 
 import gls.CompilableTestSupport
 
-public class ConstructorDelegationTest extends CompilableTestSupport {
+class ConstructorDelegationTest extends CompilableTestSupport {
 
-    public void testThisCallWithParameter() {
+    void testThisCallWithParameter() {
         assertScript """
             class A {
                 def foo
@@ -34,7 +34,7 @@ public class ConstructorDelegationTest extends CompilableTestSupport {
         """
     }
 
-    public void testThisCallWithoutParameter() {
+    void testThisCallWithoutParameter() {
         assertScript """
             class A {
                 def foo
@@ -46,7 +46,7 @@ public class ConstructorDelegationTest extends CompilableTestSupport {
         """
     }
 
-    public void testThisConstructorCallNotOnFirstStmt() {
+    void testThisConstructorCallNotOnFirstStmt() {
         shouldNotCompile """
             class ThisConstructorCall {
                 public ThisConstructorCall() {
@@ -61,7 +61,7 @@ public class ConstructorDelegationTest extends CompilableTestSupport {
         """
     }
 
-    public void testSuperConstructorCallNotOnFirstStmt() {
+    void testSuperConstructorCallNotOnFirstStmt() {
         shouldNotCompile """
             class SuperConstructorCall {
                 public SuperConstructorCall() {
@@ -73,7 +73,7 @@ public class ConstructorDelegationTest extends CompilableTestSupport {
         """
     }
 
-    public void testConstructorDelegationWithThisOrSuperInArgs() {
+    void testConstructorDelegationWithThisOrSuperInArgs() {
         def scriptStr
         // all 4 cases below were compiling earlier but giving VerifyError at runtime
         scriptStr = """
@@ -120,7 +120,7 @@ public class ConstructorDelegationTest extends CompilableTestSupport {
     }
 
     // GROOVY-6618
-    public void testVarsConstructor() {
+    void testVarsConstructor() {
         assertScript '''
             class Foo {
                 public info
diff --git a/src/test/gls/invocation/CovariantReturnTest.groovy b/src/test/gls/invocation/CovariantReturnTest.groovy
index 407c190..1af5daa 100644
--- a/src/test/gls/invocation/CovariantReturnTest.groovy
+++ b/src/test/gls/invocation/CovariantReturnTest.groovy
@@ -20,7 +20,7 @@ package gls.invocation
 
 import gls.CompilableTestSupport
 
-public class CovariantReturnTest extends CompilableTestSupport {
+class CovariantReturnTest extends CompilableTestSupport {
 
     void testCovariantReturn() {
         assertScript """
diff --git a/src/test/gls/invocation/MethodSelectionTest.groovy b/src/test/gls/invocation/MethodSelectionTest.groovy
index ae131ea..e70d427 100644
--- a/src/test/gls/invocation/MethodSelectionTest.groovy
+++ b/src/test/gls/invocation/MethodSelectionTest.groovy
@@ -20,13 +20,13 @@ package gls.invocation
 
 import gls.CompilableTestSupport
 
-public class MethodSelectionTest extends CompilableTestSupport {
+class MethodSelectionTest extends CompilableTestSupport {
 
   /**
    * This test ensures Groovy can choose a method based on interfaces.
    * Choosing such an interface should not be hidden by subclasses.
    */
-  public void testMostSpecificInterface() {
+  void testMostSpecificInterface() {
     assertScript """
       interface A{}
       interface B extends A{}
@@ -61,7 +61,7 @@ public class MethodSelectionTest extends CompilableTestSupport {
     """
   }
   
-  public void testMostGeneralForNull() {
+  void testMostGeneralForNull() {
     // we use the same signatures with different method orders,
     // because we want to catch method ordering bugs
     assertScript """
diff --git a/src/test/gls/invocation/StaticMethodInvocationTest.groovy b/src/test/gls/invocation/StaticMethodInvocationTest.groovy
index ca581d8..01cce85 100644
--- a/src/test/gls/invocation/StaticMethodInvocationTest.groovy
+++ b/src/test/gls/invocation/StaticMethodInvocationTest.groovy
@@ -20,7 +20,7 @@ package gls.invocation
 
 import gls.CompilableTestSupport
 
-public class StaticMethodInvocationTest extends CompilableTestSupport {
+class StaticMethodInvocationTest extends CompilableTestSupport {
 
     void testDifferentCalls() {
         // GROOVY-2409
diff --git a/src/test/gls/property/MetaClassOverridingTest.groovy b/src/test/gls/property/MetaClassOverridingTest.groovy
index 0fab9ce..27566cf 100644
--- a/src/test/gls/property/MetaClassOverridingTest.groovy
+++ b/src/test/gls/property/MetaClassOverridingTest.groovy
@@ -22,7 +22,7 @@ import gls.CompilableTestSupport
 
 class MetaClassOverridingTest extends CompilableTestSupport {
 
-    public void testOverridingMetaClassProperty() {
+    void testOverridingMetaClassProperty() {
         shouldCompile """
             class A {
                  private MetaClass metaClass
diff --git a/src/test/gls/scope/BlockScopeVisibilityTest.groovy b/src/test/gls/scope/BlockScopeVisibilityTest.groovy
index 1ce75c0..c70cc1f 100644
--- a/src/test/gls/scope/BlockScopeVisibilityTest.groovy
+++ b/src/test/gls/scope/BlockScopeVisibilityTest.groovy
@@ -22,7 +22,7 @@ import gls.CompilableTestSupport
 
 class BlockScopeVisibilityTest extends CompilableTestSupport {
 
-    public void testForLoopVariableNotVisibleOutside() {
+    void testForLoopVariableNotVisibleOutside() {
         assertScript """
             i=1
             for (i in [2,3]) {}
@@ -30,7 +30,7 @@ class BlockScopeVisibilityTest extends CompilableTestSupport {
         """
     }
 
-    public void testCatchParameterNotVisibleInOtherCatch() {
+    void testCatchParameterNotVisibleInOtherCatch() {
         shouldFail(MissingPropertyException) {
             try {
                 throw new RuntimeException("not important");
@@ -43,12 +43,12 @@ class BlockScopeVisibilityTest extends CompilableTestSupport {
         }
     }
 
-    public void testInnerClosureCanAccessImplicitItOfOuterClosure() {
+    void testInnerClosureCanAccessImplicitItOfOuterClosure() {
         def c = { {-> it}}
         assert c(1)() == 1
     }
 
-    public void testForLoopStatement() {
+    void testForLoopStatement() {
         // this example requires not to put the declaration
         // into a block !
         if (false)
diff --git a/src/test/gls/scope/ClassVariableHidingTest.groovy b/src/test/gls/scope/ClassVariableHidingTest.groovy
index dfe6f50..3e6789f 100644
--- a/src/test/gls/scope/ClassVariableHidingTest.groovy
+++ b/src/test/gls/scope/ClassVariableHidingTest.groovy
@@ -20,20 +20,20 @@ package gls.scope;
 
 import gls.CompilableTestSupport
 
-public class ClassVariableHidingTest extends CompilableTestSupport {
+class ClassVariableHidingTest extends CompilableTestSupport {
 
-   def foo=1;
-   def bar=2;
-   
-   public void testFooHiding() {
-     assert foo==1
-     def foo = 5
-     assert foo == 5
-   }
-   
-   public void testBarHiding() {
-     assert bar==2
-     def bar = 5
-     assert bar == 5
-   }
- }
\ No newline at end of file
+    def foo = 1;
+    def bar = 2;
+
+    void testFooHiding() {
+        assert foo == 1
+        def foo = 5
+        assert foo == 5
+    }
+
+    void testBarHiding() {
+        assert bar == 2
+        def bar = 5
+        assert bar == 5
+    }
+}
\ No newline at end of file
diff --git a/src/test/gls/scope/MultipleDefinitionOfSameVariableTest.groovy b/src/test/gls/scope/MultipleDefinitionOfSameVariableTest.groovy
index 54d3d86..a113f13 100644
--- a/src/test/gls/scope/MultipleDefinitionOfSameVariableTest.groovy
+++ b/src/test/gls/scope/MultipleDefinitionOfSameVariableTest.groovy
@@ -20,9 +20,9 @@ package gls.scope
 
 import gls.CompilableTestSupport
 
-public class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport {
+class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport {
 
-    public void testInSameBlock() {
+    void testInSameBlock() {
         shouldNotCompile """
             def foo = 1
             def foo = 2
@@ -38,7 +38,7 @@ public class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport
         """
     }
 
-    public void testInSubBlocks() {
+    void testInSubBlocks() {
         shouldNotCompile """
              def foo = 1
              5.times { def foo=2 }
@@ -60,7 +60,7 @@ public class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport
         """
     }
 
-    public void testInNestedClosure() {
+    void testInNestedClosure() {
         shouldNotCompile """
             def foo = 1
             5.times { 6.times {def foo=2 }
@@ -73,7 +73,7 @@ public class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport
         """
     }
 
-    public void testBindingHiding() {
+    void testBindingHiding() {
         assertScript """
             foo = 1
             def foo = 3
@@ -83,7 +83,7 @@ public class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport
         """
     }
 
-    public void testBindingAccessInMethod() {
+    void testBindingAccessInMethod() {
         assertScript """
             def methodUsingBinding() {
                 try {
@@ -98,7 +98,7 @@ public class MultipleDefinitionOfSameVariableTest extends CompilableTestSupport
         """
     }
 
-    public void testMultipleOfSameName() {
+    void testMultipleOfSameName() {
         shouldNotCompile """
             class DoubleField {
                 def zero = 0
diff --git a/src/test/gls/scope/NameResolvingTest.groovy b/src/test/gls/scope/NameResolvingTest.groovy
index d53e935..41c2be0 100644
--- a/src/test/gls/scope/NameResolvingTest.groovy
+++ b/src/test/gls/scope/NameResolvingTest.groovy
@@ -21,19 +21,19 @@ package gls.scope
 import gls.CompilableTestSupport
 
 class NameResolvingTest extends CompilableTestSupport {
-    public void testVariableNameEqualsToAClassName() {
+    void testVariableNameEqualsToAClassName() {
         Object String = ""
         assert String == ""
         assert String.class == java.lang.String
     }
 
-    public void testVariableNameEqualsCurrentClassName() {
+    void testVariableNameEqualsCurrentClassName() {
         Object NameResolvingTest = ""
         assert NameResolvingTest == ""
         assert NameResolvingTest.class == java.lang.String.class
     }
 
-    public void testClassNoVariableInStaticMethod() {
+    void testClassNoVariableInStaticMethod() {
         assertScript """
             static def foo() {
                 Class.forName('java.lang.Integer')
@@ -42,20 +42,20 @@ class NameResolvingTest extends CompilableTestSupport {
         """
     }
 
-    public void testInAsDefAllowedInPackageNames() {
+    void testInAsDefAllowedInPackageNames() {
         shouldCompile """
             package as.in.def
             class X {}
         """
     }
 
-    public void testAssignmentToNonLocalVariableWithSameNameAsClass() {
+    void testAssignmentToNonLocalVariableWithSameNameAsClass() {
         shouldNotCompile """
             String = 1
         """
     }
 
-    public void testClassUsageInSuper() {
+    void testClassUsageInSuper() {
         shouldCompile """
             class A {A(x){}}
             class B extends A {
@@ -64,7 +64,7 @@ class NameResolvingTest extends CompilableTestSupport {
         """
     }
     
-    public void testSuperClassVariableAccess() {
+    void testSuperClassVariableAccess() {
         assertScript """
             class U {
                 public static final int uint
diff --git a/src/test/gls/scope/StaticScopeTest.groovy b/src/test/gls/scope/StaticScopeTest.groovy
index 10d2cfb..d7a016a 100644
--- a/src/test/gls/scope/StaticScopeTest.groovy
+++ b/src/test/gls/scope/StaticScopeTest.groovy
@@ -20,9 +20,9 @@ package gls.scope
 
 import gls.CompilableTestSupport
 
-public class StaticScopeTest extends CompilableTestSupport {
+class StaticScopeTest extends CompilableTestSupport {
 
-    public void testNormalStaticScopeInScript() {
+    void testNormalStaticScopeInScript() {
         shouldNotCompile """
         static foo() {
             foo = 1
@@ -36,7 +36,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testStaticImportInclass() {
+    void testStaticImportInclass() {
         assertScript """
         import static java.lang.Math.*
         class B {
@@ -45,7 +45,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testStaticMethodInConstructor() {
+    void testStaticMethodInConstructor() {
         assertScript """
         class B {
             def instanceVariable = 0
@@ -59,7 +59,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testStaticMethodInSpecialConstructorCall() {
+    void testStaticMethodInSpecialConstructorCall() {
         assertScript """
         class A {
             def instanceVariable = 0
@@ -84,7 +84,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testStaticImportProperty() {
+    void testStaticImportProperty() {
         assertScript """
         import static A.*
         class B {
@@ -94,7 +94,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testNormalStaticScopeInClass() {
+    void testNormalStaticScopeInClass() {
         assertScript """
         class A {
             static i
@@ -116,7 +116,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testClosureInStaticScope() {
+    void testClosureInStaticScope() {
         shouldCompile """
         5.times { foo=2 }
         """
@@ -126,7 +126,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testScriptMethodCall() {
+    void testScriptMethodCall() {
         assertScript """
         import static java.util.Calendar.getInstance as now
         def now = now().time
@@ -145,7 +145,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testFullyQualifiedClassName() {
+    void testFullyQualifiedClassName() {
         assertScript """
         static foo() {java.lang.Integer}
         assert foo() == java.lang.Integer
@@ -160,7 +160,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testStaticPropertyInit() {
+    void testStaticPropertyInit() {
         // GROOVY-1910
         assertScript """
         class Foo {
@@ -182,7 +182,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
 
-    public void testSpecialConstructorAccess() {
+    void testSpecialConstructorAccess() {
         shouldCompile """
         class A{ A(x){} }
         class B extends A {
@@ -221,7 +221,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
     
-    public void testStaticMethodAccessingDynamicField() {
+    void testStaticMethodAccessingDynamicField() {
         shouldFail MissingMethodException, """
             class A {
                 def x = { }
@@ -231,7 +231,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
     
-    public void testStaticThisWithClass() {
+    void testStaticThisWithClass() {
         assertScript """
             static foo(){this}
             assert foo() instanceof Class
@@ -244,7 +244,7 @@ public class StaticScopeTest extends CompilableTestSupport {
         """
     }
     
-    public void testConstructorParameterDefault() {
+    void testConstructorParameterDefault() {
         shouldNotCompile """
             class Child {
                 Child(nr=map.B) {super(nr)}
diff --git a/src/test/gls/statements/DeclarationTest.groovy b/src/test/gls/statements/DeclarationTest.groovy
index 5311c0b..0ec877e 100644
--- a/src/test/gls/statements/DeclarationTest.groovy
+++ b/src/test/gls/statements/DeclarationTest.groovy
@@ -19,32 +19,33 @@
 package gls.statements
 
 import gls.CompilableTestSupport
+import org.codehaus.groovy.runtime.typehandling.GroovyCastException
 
-public class DeclarationTest extends CompilableTestSupport {
+class DeclarationTest extends CompilableTestSupport {
 
-  
-  public void testSingleDeclarationInParenthesis() {
-      shouldNotCompile """
-         (def a=1).method()
-      """      
-      shouldCompile """
-         (a=1).method()
-      """
-  }
-  
-  public void testNullAssignmentToPrimitive() {
-      shouldFail (org.codehaus.groovy.runtime.typehandling.GroovyCastException, """
-          int x = null
-      """)
-      assertScript """
-          Integer x = null
-      """
-  }
-  
-  public void testNullAssignmentToPrimitiveForSharedVariable() {
-      shouldFail(org.codehaus.groovy.runtime.typehandling.GroovyCastException, """
-          int i = null
-          def c = {i}
-      """)
-  }
+
+    void testSingleDeclarationInParenthesis() {
+        shouldNotCompile """
+            (def a=1).method()
+        """
+        shouldCompile """
+            (a=1).method()
+        """
+    }
+
+    void testNullAssignmentToPrimitive() {
+        shouldFail(GroovyCastException, """
+            int x = null
+        """)
+        assertScript """
+            Integer x = null
+        """
+    }
+
+    void testNullAssignmentToPrimitiveForSharedVariable() {
+        shouldFail(GroovyCastException, """
+            int i = null
+            def c = {i}
+        """)
+    }
 }
\ No newline at end of file
diff --git a/src/test/gls/statements/ReturnTest.groovy b/src/test/gls/statements/ReturnTest.groovy
index 0d1b437..9785e05 100644
--- a/src/test/gls/statements/ReturnTest.groovy
+++ b/src/test/gls/statements/ReturnTest.groovy
@@ -20,9 +20,9 @@ package gls.statements
 
 import gls.CompilableTestSupport
 
-public class ReturnTest extends CompilableTestSupport {
+class ReturnTest extends CompilableTestSupport {
 
-  public void testObjectInitializer() {
+  void testObjectInitializer() {
       shouldNotCompile """
          class A {
             {return}
@@ -30,7 +30,7 @@ public class ReturnTest extends CompilableTestSupport {
       """
   }
   
-  public void testStaticInitializer() {
+  void testStaticInitializer() {
       assertScript """
          class A {
              static foo=2
@@ -40,7 +40,7 @@ public class ReturnTest extends CompilableTestSupport {
       """      
   }
 
-  public void testReturnAdditionInFinally() {
+  void testReturnAdditionInFinally() {
       //GROOVY-7065
       assertScript """
         class CountDown { int counter = 10 }
diff --git a/src/test/gls/syntax/AssertTest.groovy b/src/test/gls/syntax/AssertTest.groovy
index c7922fb..d62e9a8 100644
--- a/src/test/gls/syntax/AssertTest.groovy
+++ b/src/test/gls/syntax/AssertTest.groovy
@@ -18,7 +18,7 @@
  */
 package gls.syntax
 
-public class AssertTest extends gls.CompilableTestSupport {
+class AssertTest extends gls.CompilableTestSupport {
   
   void testAssignment() {
     // don't allow "=" here, it most certainly must be a "=="
diff --git a/src/test/gls/syntax/MethodCallValidationTest.groovy b/src/test/gls/syntax/MethodCallValidationTest.groovy
index 9fe6d52..cd46978 100644
--- a/src/test/gls/syntax/MethodCallValidationTest.groovy
+++ b/src/test/gls/syntax/MethodCallValidationTest.groovy
@@ -18,7 +18,7 @@
  */
 package gls.syntax
 
-public class MethodCallValidationTest extends gls.CompilableTestSupport {
+class MethodCallValidationTest extends gls.CompilableTestSupport {
 
     void testDeclarationInMethodCall() {
         shouldNotCompile """
diff --git a/src/test/gls/syntax/NumberLiteralTest.groovy b/src/test/gls/syntax/NumberLiteralTest.groovy
index 72f0792..71591d8 100644
--- a/src/test/gls/syntax/NumberLiteralTest.groovy
+++ b/src/test/gls/syntax/NumberLiteralTest.groovy
@@ -18,7 +18,9 @@
  */
 package gls.syntax
 
-public class NumberLiteralTest extends gls.CompilableTestSupport {
+import gls.CompilableTestSupport
+
+class NumberLiteralTest extends CompilableTestSupport {
 
     void testLargeNumbersOverflowing() {
         shouldCompile '''
diff --git a/src/test/gls/syntax/OldClosureSyntaxRemovalTest.groovy b/src/test/gls/syntax/OldClosureSyntaxRemovalTest.groovy
index 6526968..364d365 100644
--- a/src/test/gls/syntax/OldClosureSyntaxRemovalTest.groovy
+++ b/src/test/gls/syntax/OldClosureSyntaxRemovalTest.groovy
@@ -18,26 +18,28 @@
  */
 package gls.syntax
 
-public class OldClosureSyntaxRemovalTest extends gls.CompilableTestSupport {
-  def a = 2
-  def b = 3
-  
-  void testOneParameter(){
-    def newClosure = {a -> a}
-    def oldClosure = {a|b}
-    assert newClosure(1)==1
-    assert oldClosure.getMaximumNumberOfParameters() == 1
-    // the old closure would have cimply returned b
-    // after removal this is the logic or
-    assert oldClosure(1)==(a|b)
-  }
-  
-  void testMultipleParameters() {
-    shouldNotCompile """
-       c = {a,b|a+b}
-    """
-    shouldCompile   """
-       c = { a,b -> a+b }
-    """
-  }
+import gls.CompilableTestSupport
+
+class OldClosureSyntaxRemovalTest extends CompilableTestSupport {
+    def a = 2
+    def b = 3
+
+    void testOneParameter() {
+        def newClosure = { a -> a }
+        def oldClosure = { a | b }
+        assert newClosure(1) == 1
+        assert oldClosure.getMaximumNumberOfParameters() == 1
+        // the old closure would have cimply returned b
+        // after removal this is the logic or
+        assert oldClosure(1) == (a | b)
+    }
+
+    void testMultipleParameters() {
+        shouldNotCompile """
+            c = {a,b|a+b}
+        """
+        shouldCompile """
+            c = { a,b -> a+b }
+        """
+    }
 }
\ No newline at end of file
diff --git a/src/test/gls/syntax/OldPropertySyntaxRemovalTest.groovy b/src/test/gls/syntax/OldPropertySyntaxRemovalTest.groovy
index ea6d0de..422f7ce 100644
--- a/src/test/gls/syntax/OldPropertySyntaxRemovalTest.groovy
+++ b/src/test/gls/syntax/OldPropertySyntaxRemovalTest.groovy
@@ -18,13 +18,15 @@
  */
 package gls.syntax
 
-public class OldPropertySyntaxRemovalTest extends gls.CompilableTestSupport {
-  
-  void testMultipleParameters() {
-    shouldNotCompile """
-       class C {
-         @Property foo
-       }
-    """
-  }
+import gls.CompilableTestSupport
+
+class OldPropertySyntaxRemovalTest extends CompilableTestSupport {
+
+    void testMultipleParameters() {
+        shouldNotCompile """
+            class C {
+                @Property foo
+            }
+        """
+    }
 }
\ No newline at end of file
diff --git a/src/test/gls/syntax/OldSpreadTest.groovy b/src/test/gls/syntax/OldSpreadTest.groovy
index cd8ec7d..408744c 100644
--- a/src/test/gls/syntax/OldSpreadTest.groovy
+++ b/src/test/gls/syntax/OldSpreadTest.groovy
@@ -18,12 +18,14 @@
  */
 package gls.syntax
 
-public class OldSpreadTest extends gls.CompilableTestSupport {
-  
-  void testSpreadStatement() {
-    // don't allow spread outside a method call
-    shouldNotCompile """
-       *x       
-    """
-  }
+import gls.CompilableTestSupport
+
+class OldSpreadTest extends CompilableTestSupport {
+
+    void testSpreadStatement() {
+        // don't allow spread outside a method call
+        shouldNotCompile """
+            *x       
+        """
+    }
 }
\ No newline at end of file
diff --git a/src/test/gls/syntax/ParsingTest.groovy b/src/test/gls/syntax/ParsingTest.groovy
index f126c2a..c854c90 100644
--- a/src/test/gls/syntax/ParsingTest.groovy
+++ b/src/test/gls/syntax/ParsingTest.groovy
@@ -18,7 +18,9 @@
  */
 package gls.syntax
 
-public class ParsingTest extends gls.CompilableTestSupport {
+import gls.CompilableTestSupport
+
+class ParsingTest extends CompilableTestSupport {
     void testExpressionParsingWithCastingInFrontOfAClosure() {
         int[] numbers = new int[3]
 
diff --git a/src/test/gls/types/BooleanExpressionConversionTest.groovy b/src/test/gls/types/BooleanExpressionConversionTest.groovy
index 5c8ebdc..63358f4 100644
--- a/src/test/gls/types/BooleanExpressionConversionTest.groovy
+++ b/src/test/gls/types/BooleanExpressionConversionTest.groovy
@@ -18,7 +18,9 @@
  */
 package gls.types
 
-public class BooleanExpressionConversionTest extends gls.CompilableTestSupport {
+import gls.CompilableTestSupport
+
+class BooleanExpressionConversionTest extends CompilableTestSupport {
     void testInt() {
         assertScript """
             boolean foo(int i){
diff --git a/src/test/gls/types/GroovyCastTest.groovy b/src/test/gls/types/GroovyCastTest.groovy
index a63aa33..fb86cff 100644
--- a/src/test/gls/types/GroovyCastTest.groovy
+++ b/src/test/gls/types/GroovyCastTest.groovy
@@ -18,7 +18,9 @@
  */
 package gls.types
 
-public class GroovyCastTest extends gls.CompilableTestSupport {
+import gls.CompilableTestSupport
+
+class GroovyCastTest extends CompilableTestSupport {
     void testSAMVariable() {
         assertScript """
             interface SAM { def foo(); }
diff --git a/src/test/gls/types/OperationsResultTypeTest.groovy b/src/test/gls/types/OperationsResultTypeTest.groovy
index 162d39c..65a7ea4 100644
--- a/src/test/gls/types/OperationsResultTypeTest.groovy
+++ b/src/test/gls/types/OperationsResultTypeTest.groovy
@@ -18,30 +18,32 @@
  */
 package gls.types
 
-public class OperationsResultTypeTest extends gls.CompilableTestSupport {
-  
-  void testDeclaredTypeIsKept() {
-      assertScript """
-          def list = [10,20,30]
-          Iterator it = list.iterator()
-          try {
-              it++
-              assert false
-          } catch  (ClassCastException) {
-              assert true
-          }
-      """
-  }
+import gls.CompilableTestSupport
 
-  void testDeclaredTypeIsKeptForSharedVariable() {
-    assertScript '''
-        float myFloat = 40f
-        myFloat -= 20f
-        assert myFloat.class == Float
-        println "$myFloat"
-        (0..1).each { i ->
+class OperationsResultTypeTest extends CompilableTestSupport {
+
+    void testDeclaredTypeIsKept() {
+        assertScript """
+            def list = [10,20,30]
+            Iterator it = list.iterator()
+            try {
+                it++
+                assert false
+            } catch  (ClassCastException) {
+                assert true
+            }
+        """
+    }
+
+    void testDeclaredTypeIsKeptForSharedVariable() {
+        assertScript '''
+            float myFloat = 40f
+            myFloat -= 20f
             assert myFloat.class == Float
-        }
-    '''
-  }
+            println "$myFloat"
+            (0..1).each { i ->
+                assert myFloat.class == Float
+            }
+        '''
+    }
 }


Mime
View raw message