You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/08/19 05:52:41 UTC

[groovy] branch master updated (6de1ad8 -> c56326a)

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

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


    from 6de1ad8  formatting
     new b7c1710  formatting
     new c56326a  formatting and convert test to JUnit4

The 2 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:
 src/test/groovy/bugs/Groovy2951.groovy             |  22 ++--
 src/test/groovy/bugs/Groovy4418Bug.groovy          | 137 +++++++++++----------
 .../classgen/asm/sc/bugs/Groovy7276Bug.groovy      |  95 +++++++-------
 3 files changed, 127 insertions(+), 127 deletions(-)


[groovy] 01/02: formatting

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

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

commit b7c1710246028b9544bac5cfa99b5e21e3364ce3
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Aug 19 15:52:06 2019 +1000

    formatting
---
 src/test/groovy/bugs/Groovy2951.groovy             | 22 ++---
 .../classgen/asm/sc/bugs/Groovy7276Bug.groovy      | 95 ++++++++++------------
 2 files changed, 54 insertions(+), 63 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy2951.groovy b/src/test/groovy/bugs/Groovy2951.groovy
index 20b142d..9574d72 100644
--- a/src/test/groovy/bugs/Groovy2951.groovy
+++ b/src/test/groovy/bugs/Groovy2951.groovy
@@ -24,12 +24,11 @@ final class Groovy2951 {
 
     @Test
     void testInstanceLevelMissingMethodWithRegularClosure1() {
-        Groovy2951BugClass1.metaClass.methodMissing = {
-            method, args ->
+        Groovy2951BugClass1.metaClass.methodMissing = { method, args ->
             return method
         }
-        def result = new Groovy2951BugClass1().test1("arg1", "arg2")
-        assert result == "test1"
+        def result = new Groovy2951BugClass1().test1('arg1', 'arg2')
+        assert result == 'test1'
     }
 
     @Test
@@ -37,22 +36,23 @@ final class Groovy2951 {
         Groovy2951BugClass2.metaClass.methodMissing << { method, args ->
             return method
         }
-        def result = new Groovy2951BugClass2().test2("arg1", "arg2")
-        assert result == "test2"
+        def result = new Groovy2951BugClass2().test2('arg1', 'arg2')
+        assert result == 'test2'
     }
 
     @Test
     void testInstanceLevelMissingMethodWithMethodClosure() {
         Groovy2951BugClass3.metaClass.methodMissing = Groovy2951BugClass3.&mm
-
-        def result = new Groovy2951BugClass3().test3("arg3", "arg4")
-        assert result == "test3"
+        def result = new Groovy2951BugClass3().test3('arg1', 'arg2')
+        assert result == 'test3'
     }
 }
 
-class Groovy2951BugClass1 {}
+class Groovy2951BugClass1 {
+}
 
-class Groovy2951BugClass2 {}
+class Groovy2951BugClass2 {
+}
 
 class Groovy2951BugClass3 {
     static def mm(method, args) {
diff --git a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7276Bug.groovy b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7276Bug.groovy
index 5f2e493..3dc71f6 100644
--- a/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7276Bug.groovy
+++ b/src/test/org/codehaus/groovy/classgen/asm/sc/bugs/Groovy7276Bug.groovy
@@ -16,79 +16,70 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-
-
-
-
 package org.codehaus.groovy.classgen.asm.sc.bugs
 
 import groovy.transform.NotYetImplemented
 import groovy.transform.stc.StaticTypeCheckingTestCase
 import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
 
-class Groovy7276Bug extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
+final class Groovy7276Bug extends StaticTypeCheckingTestCase implements StaticCompilationTestSupport {
+
     void testShouldGoThroughPrivateBridgeAccessor() {
-            assertScript '''
-                class Foo {
-                    private i = 1
-                    def m() { new String().with {i}}
-                }
-                assert new Foo().m() == 1
-                class Bar extends Foo {}
-                assert new Bar().m() == 1
+        assertScript '''
+            class Foo {
+                private i = 1
+                def m() { new String().with {i}}
+            }
+            assert new Foo().m() == 1
+            class Bar extends Foo {}
+            assert new Bar().m() == 1
         '''
     }
 
     void testShouldGoThroughPrivateBridgeMethod() {
-            assertScript '''
-                class Foo {
-                    private i = 1
-                    private def pvI() { i }
-                    def m() { new String().with {pvI()}}
-                }
-                assert new Foo().m() == 1
-                class Bar extends Foo {}
-                assert new Bar().m() == 1
+        assertScript '''
+            class Foo {
+                private i = 1
+                private def pvI() { i }
+                def m() { new String().with {pvI()}}
+            }
+            assert new Foo().m() == 1
+            class Bar extends Foo {}
+            assert new Bar().m() == 1
         '''
     }
 
     void testPrivateAccessInInnerClass() {
-        assertScript '''import groovy.transform.CompileStatic
-
-class Outer {
-    private static class Inner {
-
-        private Set<String> variablesToCheck = []
-
-        private void checkAssertions(String name) {
-            Runnable r = {
-                def candidates = variablesToCheck.findAll { it == name }
+        assertScript '''
+            class Outer {
+                private static class Inner {
+                    private Set<String> variablesToCheck = []
+                    private void checkAssertions(String name) {
+                        Runnable r = {
+                            def candidates = variablesToCheck.findAll { it == name }
+                        }
+                        r.run()
+                    }
+                }
+                static void test() {
+                    new Inner().checkAssertions('name')
+                }
             }
-            r.run()
-        }
-    }
-
-    static void test() {
-        new Inner().checkAssertions('name')
-    }
-}
-
-Outer.test()'''
+            Outer.test()
+        '''
     }
 
     @NotYetImplemented
     // GROOVY-7304
     void testShouldGoThroughPrivateBridgeAccessorWithWriteAccess() {
-            assertScript '''
-                class Foo {
-                    private int i = 1
-                    def m() { new String().with {++i}}
-                }
-                assert new Foo().m() == 2
-                class Bar extends Foo {}
-                assert new Bar().m() == 2
+        assertScript '''
+            class Foo {
+                private int i = 1
+                def m() { new String().with { ++i } }
+            }
+            assert new Foo().m() == 2
+            class Bar extends Foo {}
+            assert new Bar().m() == 2
         '''
     }
-
-
 }


[groovy] 02/02: formatting and convert test to JUnit4

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

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

commit c56326a50b3e39a09d0e5dac3d513b84bc518567
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Aug 19 15:52:27 2019 +1000

    formatting and convert test to JUnit4
---
 src/test/groovy/bugs/Groovy4418Bug.groovy | 137 ++++++++++++++++--------------
 1 file changed, 73 insertions(+), 64 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy4418Bug.groovy b/src/test/groovy/bugs/Groovy4418Bug.groovy
index 3e8a93c..33fe40b 100644
--- a/src/test/groovy/bugs/Groovy4418Bug.groovy
+++ b/src/test/groovy/bugs/Groovy4418Bug.groovy
@@ -18,9 +18,14 @@
  */
 package groovy.bugs
 
-import gls.CompilableTestSupport
+import org.junit.Test
 
-class Groovy4418Bug extends CompilableTestSupport {
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.util.GroovyAssert.shouldFail
+
+final class Groovy4418Bug {
+
+    @Test
     void testStaticFieldAccess() {
         assertScript '''
             class Base {
@@ -35,31 +40,31 @@ class Groovy4418Bug extends CompilableTestSupport {
         '''
     }
 
-    // additional test for GROOVY-6183
+    @Test // GROOVY-6183
     void testStaticAttributeAccess() {
         assertScript '''
-        class A {
-            static protected int x
-            public static void reset() { this.@x = 2 }
-        }
-        assert A.x == 0
-        assert A.@x == 0
-        A.reset()
-        assert A.x == 2
-        assert A.@x == 2
+            class A {
+                static protected int x
+                public static void reset() { this.@x = 2 }
+            }
+            assert A.x == 0
+            assert A.@x == 0
+            A.reset()
+            assert A.x == 2
+            assert A.@x == 2
         '''
     }
 
-    // GROOVY-8385
-    void testParentClassStaticAttributeSetAccessShouldNotCallSetter() {
+    @Test // GROOVY-8385
+    void testParentClassStaticAttributeSetAccess() {
         assertScript '''
             class A {
                 static protected p
-                static setP(){def val}
-                static getP(){this.@p}
+                static setP(def val){ p = 2 }
+                static getP(){ -1 }
             }
             class B extends A {
-              def m(){this.@p = 1}
+                def m(){ this.@p = 1 }
             }
             def x = new B()
             assert A.@p == null
@@ -70,11 +75,11 @@ class Groovy4418Bug extends CompilableTestSupport {
         assertScript '''
             class A {
                 static protected p
-                static setP(){def val}
-                static getP(){this.@p}
+                static setP(def val){ p = 2 }
+                static getP(){ -1 }
             }
             class B extends A {
-              def m(){super.@p = 1}
+                def m(){ super.@p = 1 }
             }
             def x = new B()
             assert A.@p == null
@@ -85,12 +90,12 @@ class Groovy4418Bug extends CompilableTestSupport {
         assertScript '''
             class A {
                 static protected p
-                static setP(){def val}
-                static getP(){this.@p}
+                static setP(def val){ p = 2 }
+                static getP(){ -1 }
             }
             class AA extends A {}
             class B extends AA {
-              def m(){super.@p = 1}
+                def m(){ super.@p = 1 }
             }
             def x = new B()
             assert A.@p == null
@@ -99,16 +104,16 @@ class Groovy4418Bug extends CompilableTestSupport {
         '''
     }
 
-    // GROOVY-8385
-    void testParentClassNonStaticAttributeSetAccessShouldNotCallSetter() {
+    @Test // GROOVY-8385
+    void testParentClassNonStaticAttributeSetAccess() {
         assertScript '''
             class A {
                 protected p
-                void setP(def val){}
-                def getP(){p}
+                void setP(def val) { p = 2 }
+                def getP() { -1 }
             }
             class B extends A {
-              def m(){this.@p = 1}
+                def m() { this.@p = 1 }
             }
             def x = new B()
             assert x.@p == null
@@ -119,11 +124,11 @@ class Groovy4418Bug extends CompilableTestSupport {
         assertScript '''
             class A {
                 protected p
-                void setP(def val){}
-                def getP(){p}
+                void setP(def val) { p = 2 }
+                def getP() { -1 }
             }
             class B extends A {
-              def m(){super.@p = 1}
+                def m() { super.@p = 1 }
             }
             def x = new B()
             assert x.@p == null
@@ -134,12 +139,12 @@ class Groovy4418Bug extends CompilableTestSupport {
         assertScript '''
             class A {
                 protected p
-                void setP(def val){}
-                def getP(){p}
+                void setP(def val) { p = 2 }
+                def getP() { -1 }
             }
             class AA extends A {}
             class B extends AA {
-              def m(){super.@p = 1}
+                def m() { super.@p = 1 }
             }
             def x = new B()
             assert x.@p == null
@@ -148,39 +153,43 @@ class Groovy4418Bug extends CompilableTestSupport {
         '''
     }
 
-    // GROOVY-8385
+    @Test // GROOVY-8385
     void testParentClassPrivateStaticAttributeSetAccessShouldCallSetter() {
-        shouldFail(MissingFieldException, '''
-            class A {
-                static private p
-                static setP(){def val}
-                static getP(){this.@p}
-            }
-            class B extends A {
-              def m(){this.@p = 1}
-            }
-            def x = new B()
-            assert A.@p == null
-            x.m()
-        ''')
+        shouldFail(MissingFieldException) {
+            Eval.me'''
+                class A {
+                    static private p
+    
+                    void setP(def val) { p = 2 }
+    
+                    def getP() { -1 }
+                }
+                class B extends A {
+                    def m() { this.@p = 1 }
+                }
+                def x = new B()
+                assert A.@p == null
+                x.m()
+            '''
+        }
     }
 
-    // GROOVY-8385
+    @Test // GROOVY-8385
     void testParentClassPrivateNonStaticAttributeSetAccessShouldNotCallSetter() {
-        shouldFail(MissingFieldException, '''
-            class A {
-                private p
-                void setP(def val){}
-                def getP(){p}
-            }
-            class B extends A {
-              def m(){this.@p = 1}
-            }
-            def x = new B()
-            assert x.@p == null
-            x.m()
-        ''')
+        shouldFail(MissingFieldException) {
+            Eval.me'''
+                class A {
+                    private p
+                    void setP(def val) { p = 2 }
+                    def getP() { -1 }
+                }
+                class B extends A {
+                    def m() { this.@p = 1 }
+                }
+                def x = new B()
+                assert x.@p == null
+                x.m()
+        '''
+        }
     }
-
-
 }