Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X cbe975940 -> 020e14b40
Fix the test gls.generics.GenericsTest.testCompilationWithMissingClosingBracketsInGenerics (cherry picked from commit 5c63ad6) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/020e14b4 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/020e14b4 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/020e14b4 Branch: refs/heads/GROOVY_2_6_X Commit: 020e14b400c5b696acdd7b717776d6ea15022987 Parents: cbe9759 Author: sunlan <[email protected]> Authored: Sun Aug 6 00:45:00 2017 +0800 Committer: sunlan <[email protected]> Committed: Sun Aug 6 00:46:00 2017 +0800 ---------------------------------------------------------------------- src/test/gls/generics/GenericsTest.groovy | 111 +++++++++++++++++-------- 1 file changed, 75 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/020e14b4/src/test/gls/generics/GenericsTest.groovy ---------------------------------------------------------------------- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 91b9567..e7a98fa 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -357,42 +357,81 @@ import java.util.concurrent.atomic.AtomicInteger } void testCompilationWithMissingClosingBracketsInGenerics() { - shouldFailCompilationWithExpectedMessage """ - def list1 = new ArrayList<Integer() - """ - - shouldFailCompilationWithExpectedMessage """ - List<Integer list2 = new ArrayList<Integer>() - """ - - shouldFailCompilationWithExpectedMessage """ - def c = [] - for (Iterator<String i = c.iterator(); i.hasNext(); ) { } - """ - - shouldFailCompilationWithExpectedMessage """ - def m(Class<Integer someParam) {} - """ - - shouldFailCompilationWithExpectedMessage """ - abstract class ArrayList1<E extends AbstractList<E> implements List<E> {} - """ - - shouldFailCompilationWithExpectedMessage """ - abstract class ArrayList2<E> extends AbstractList<E implements List<E> {} - """ - - shouldFailCompilationWithExpectedMessage """ - abstract class ArrayList3<E> extends AbstractList<E> implements List<E {} - """ - - shouldFailCompilationWithExpectedMessage """ - def List<List<Integer> history = new ArrayList<List<Integer>>() - """ - - shouldFailCompilationWithExpectedMessage """ - def List<List<Integer>> history = new ArrayList<List<Integer>() - """ + if (CompilerConfiguration.DEFAULT.antlr2Parser) { + shouldFailCompilationWithExpectedMessage """ + def list1 = new ArrayList<Integer() + """ + + shouldFailCompilationWithExpectedMessage """ + List<Integer list2 = new ArrayList<Integer>() + """ + + shouldFailCompilationWithExpectedMessage """ + def c = [] + for (Iterator<String i = c.iterator(); i.hasNext(); ) { } + """ + + shouldFailCompilationWithExpectedMessage """ + def m(Class<Integer someParam) {} + """ + + shouldFailCompilationWithExpectedMessage """ + abstract class ArrayList1<E extends AbstractList<E> implements List<E> {} + """ + + shouldFailCompilationWithExpectedMessage """ + abstract class ArrayList2<E> extends AbstractList<E implements List<E> {} + """ + + shouldFailCompilationWithExpectedMessage """ + abstract class ArrayList3<E> extends AbstractList<E> implements List<E {} + """ + + shouldFailCompilationWithExpectedMessage """ + def List<List<Integer> history = new ArrayList<List<Integer>>() + """ + + shouldFailCompilationWithExpectedMessage """ + def List<List<Integer>> history = new ArrayList<List<Integer>() + """ + } else { + shouldFailCompilationWithMessage """ + def list1 = new ArrayList<Integer() + """, "Unexpected input: 'new ArrayList<Integer('" + + shouldFailCompilationWithMessage """ + List<Integer list2 = new ArrayList<Integer>() + """, "Unexpected input: 'list2'" + + shouldFailCompilationWithMessage """ + def c = [] + for (Iterator<String i = c.iterator(); i.hasNext(); ) { } + """, "Unexpected input: 'Iterator<String i'" + + shouldFailCompilationWithMessage """ + def m(Class<Integer someParam) {} + """, "Unexpected input: 'Class<Integer someParam'" + + shouldFailCompilationWithMessage """ + abstract class ArrayList1<E extends AbstractList<E> implements List<E> {} + """, "Unexpected input: 'implements'" + + shouldFailCompilationWithMessage """ + abstract class ArrayList2<E> extends AbstractList<E implements List<E> {} + """, "Unexpected input: 'AbstractList<E implements'" + + shouldFailCompilationWithMessage """ + abstract class ArrayList3<E> extends AbstractList<E> implements List<E {} + """, "Unexpected input: '<'" + + shouldFailCompilationWithMessage """ + def List<List<Integer> history = new ArrayList<List<Integer>>() + """, "Unexpected input: 'def List<List<Integer> history'" + + shouldFailCompilationWithMessage """ + def List<List<Integer>> history = new ArrayList<List<Integer>() + """, "Unexpected input: 'new ArrayList<List<Integer>('" + } } private void shouldFailCompilationWithExpectedMessage(scriptText) {
