groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 01/04: minor refactor
Date Mon, 21 Oct 2019 02:18:44 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 020a7e77105fe77280d53eb013bcced7fe7daf20
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Fri Oct 18 10:21:50 2019 -0500

    minor refactor
    
    (cherry picked from commit f105fc3b44f329d444b2c9db8775499329958329)
---
 src/test/groovy/bugs/Groovy9261.groovy             | 37 ++++++++++++++--------
 .../test/suite/ATestScriptThatsNoTestCase.groovy   |  4 ++-
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/src/test/groovy/bugs/Groovy9261.groovy b/src/test/groovy/bugs/Groovy9261.groovy
index 347d5c7..1581eb9 100644
--- a/src/test/groovy/bugs/Groovy9261.groovy
+++ b/src/test/groovy/bugs/Groovy9261.groovy
@@ -18,11 +18,17 @@
  */
 package groovy.bugs
 
-import groovy.test.GroovyTestCase
+import groovy.transform.CompileStatic
+import org.junit.Test
 
-class Groovy9261 extends GroovyTestCase {
+import static groovy.test.GroovyAssert.shouldFail
+
+@CompileStatic
+final class Groovy9261 {
+
+    @Test
     void testInvalidResourceInARM() {
-        String errMsg = shouldFail '''\
+        def err = shouldFail '''\
             @groovy.transform.CompileStatic
             void test() {
                 try (String str = '123') {
@@ -31,12 +37,13 @@ class Groovy9261 extends GroovyTestCase {
             test()
         '''
 
-        assert errMsg.contains('Resource[java.lang.String] in ARM should be of type AutoCloseable')
-        assert errMsg.contains('@ line 3, column 22.')
+        assert err.message.contains('Resource[java.lang.String] in ARM should be of type
AutoCloseable')
+        assert err.message.contains('@ line 3, column 22.')
     }
 
+    @Test
     void testInvalidResourceInARM2() {
-        String errMsg = shouldFail '''\
+        def err = shouldFail '''\
             @groovy.transform.CompileStatic
             void test() {
                 try (str = '123') {
@@ -45,12 +52,13 @@ class Groovy9261 extends GroovyTestCase {
             test()
         '''
 
-        assert errMsg.contains('Resource[java.lang.String] in ARM should be of type AutoCloseable')
-        assert errMsg.contains('@ line 3, column 22.')
+        assert err.message.contains('Resource[java.lang.String] in ARM should be of type
AutoCloseable')
+        assert err.message.contains('@ line 3, column 22.')
     }
 
+    @Test
     void testInvalidResourceInARM3() {
-        String errMsg = shouldFail '''\
+        def err = shouldFail '''\
             @groovy.transform.CompileStatic
             void test() {
                 try (def sr = new StringReader(''); str = '123') {
@@ -59,12 +67,13 @@ class Groovy9261 extends GroovyTestCase {
             test()
         '''
 
-        assert errMsg.contains('Resource[java.lang.String] in ARM should be of type AutoCloseable')
-        assert errMsg.contains('@ line 3, column 53.')
+        assert err.message.contains('Resource[java.lang.String] in ARM should be of type
AutoCloseable')
+        assert err.message.contains('@ line 3, column 53.')
     }
 
+    @Test
     void testInvalidResourceInEnhancedARM() {
-        String errMsg = shouldFail '''\
+        def err = shouldFail '''\
             @groovy.transform.CompileStatic
             void test() {
                 String str = '123'
@@ -74,7 +83,7 @@ class Groovy9261 extends GroovyTestCase {
             test()
         '''
 
-        assert errMsg.contains('Resource[java.lang.String] in ARM should be of type AutoCloseable')
-        assert errMsg.contains('@ line 4, column 22.')
+        assert err.message.contains('Resource[java.lang.String] in ARM should be of type
AutoCloseable')
+        assert err.message.contains('@ line 4, column 22.')
     }
 }
diff --git a/subprojects/groovy-test/src/test/groovy/groovy/test/suite/ATestScriptThatsNoTestCase.groovy
b/subprojects/groovy-test/src/test/groovy/groovy/test/suite/ATestScriptThatsNoTestCase.groovy
index 733a0d6..bc73469 100644
--- a/subprojects/groovy-test/src/test/groovy/groovy/test/suite/ATestScriptThatsNoTestCase.groovy
+++ b/subprojects/groovy-test/src/test/groovy/groovy/test/suite/ATestScriptThatsNoTestCase.groovy
@@ -16,5 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+package groovy.test.suite
+
 // used for testing ScriptTestCaseAdapter usage with AllTestSuite
-assert true
\ No newline at end of file
+assert true


Mime
View raw message