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 2017/07/08 02:12:24 UTC
groovy git commit: Fix the error message issue of
gls.generics.GenericsTest#testGenericsDiamondShortcutIllegalPosition
Repository: groovy
Updated Branches:
refs/heads/master 6c7a3fd0b -> e4d20341c
Fix the error message issue of gls.generics.GenericsTest#testGenericsDiamondShortcutIllegalPosition
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e4d20341
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e4d20341
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e4d20341
Branch: refs/heads/master
Commit: e4d20341c06fc0e53ec0ba3da58d7c8b47faf2ef
Parents: 6c7a3fd
Author: sunlan <su...@apache.org>
Authored: Sat Jul 8 10:12:15 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Jul 8 10:12:15 2017 +0800
----------------------------------------------------------------------
src/test/gls/generics/GenericsTest.groovy | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/e4d20341/src/test/gls/generics/GenericsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy
index 02a76ce..d08cd0a 100644
--- a/src/test/gls/generics/GenericsTest.groovy
+++ b/src/test/gls/generics/GenericsTest.groovy
@@ -323,9 +323,9 @@ class GenericsTest extends GenericsTestBase {
}
void testGenericsDiamondShortcutIllegalPosition() {
- shouldFailCompilationWithMessage '''
+ shouldFailCompilationWithAnyMessage '''
List<> list4 = []
- ''', 'unexpected token: <'
+ ''', ['unexpected token: <', 'Unexpected input: \'<\'']
}
void testGenericsInAsType() {
@@ -398,6 +398,7 @@ import java.util.concurrent.atomic.AtomicInteger
shouldFailCompilationWithMessage scriptText, "Missing closing bracket '>' for generics types"
}
+
private void shouldFailCompilationWithMessage(scriptText, String errorMessage) {
shouldFailCompilationWithMessages(scriptText, [errorMessage])
}
@@ -414,6 +415,23 @@ import java.util.concurrent.atomic.AtomicInteger
}
}
+ private void shouldFailCompilationWithAnyMessage(scriptText, List<String> errorMessages) {
+ try {
+ assertScript scriptText
+ fail("The script compilation should have failed as it contains generics errors, e.g. mis-matching generic brackets")
+ } catch (MultipleCompilationErrorsException mcee) {
+ def text = mcee.toString()
+
+ for (errorMessage in errorMessages) {
+ if (text.contains(errorMessage)) {
+ return
+ }
+ }
+
+ assert false, text + " can not match any expected error message: " + errorMessages
+ }
+ }
+
void testGenericsInfoForClosureParameters() {
def cl = { List<String> s -> }
def type = cl.getClass().getMethod("call", List).genericParameterTypes[0]