minor refactor
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 @@
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 @@
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 @@
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 @@
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