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:38 UTC

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

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
+}