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/05/27 18:51:43 UTC
[groovy] 01/02: refactor test
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 d06812d99109ad6919513855f6c3f696356418d0
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon May 27 16:23:43 2019 +1000
refactor test
---
src/test/groovy/bugs/Groovy9141.groovy | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/test/groovy/bugs/Groovy9141.groovy b/src/test/groovy/bugs/Groovy9141.groovy
index 0889d36..c5d707c 100644
--- a/src/test/groovy/bugs/Groovy9141.groovy
+++ b/src/test/groovy/bugs/Groovy9141.groovy
@@ -26,31 +26,39 @@ import static org.codehaus.groovy.control.ParserVersion.V_2
@CompileStatic
final class Groovy9141 extends CompilableTestSupport {
- private static final String METHOD_DEF = '''
- abstract meth() {
- println 42
- }
+ private static final String ABSTRACT_METHOD_WITH_BODY = '''
+ abstract meth() { }
'''
+ // not a language requirement but script-level check takes precedence in current implementation
void testAbstractMethodWithBodyInScript() {
- def err = shouldNotCompile METHOD_DEF
- assert err =~ / You cannot define an abstract method\[meth\] in the script. Try removing the 'abstract' /
+ def err = shouldNotCompile ABSTRACT_METHOD_WITH_BODY
+ assert err =~ / You cannot define an abstract method\[meth] in the script. Try removing the 'abstract' /
}
void testAbstractMethodWithBodyInClass() {
def err = shouldNotCompile """
class Main {
- $METHOD_DEF
+ $ABSTRACT_METHOD_WITH_BODY
}
"""
// not a language requirement but class level check takes precedence in current implementation
assert err =~ / Can't have an abstract method in a non-abstract class. /
}
+ void testAbstractMethodWithBodyInCAbstractlass() {
+ def err = shouldNotCompile """
+ abstract class Main {
+ $ABSTRACT_METHOD_WITH_BODY
+ }
+ """
+ assert err =~ / You defined an abstract method\[meth] with a body. Try removing the method body @ line /
+ }
+
void testAbstractMethodWithBodyInScript_oldParser() {
def cc = new CompilerConfiguration(parserVersion: V_2)
def err = shouldFail {
- new GroovyShell(cc).evaluate METHOD_DEF
+ new GroovyShell(cc).evaluate ABSTRACT_METHOD_WITH_BODY
}
assert err =~ / Abstract methods do not define a body/
}