diff -r a7a2720c7897 -r 1ae5988e201b test/tools/javac/lambda/MethodReferenceParserTest.java --- a/test/tools/javac/lambda/MethodReferenceParserTest.java Fri Dec 16 16:41:00 2011 -0800 +++ b/test/tools/javac/lambda/MethodReferenceParserTest.java Mon Dec 19 12:07:07 2011 +0000 @@ -24,7 +24,6 @@ /* * @test * @bug 7115052 - * @ignore 7120266 * @summary Add parser support for method references */ @@ -45,6 +44,7 @@ enum ReferenceKind { METHOD_REF("#Q##Gm"), CONSTRUCTOR_REF("#Q##Gnew"), + FALSE_REF("min < max"), ERR_SUPER("#Q##Gsuper"), ERR_METH0("#Q##Gm()"), ERR_METH1("#Q##Gm(X)"), @@ -76,6 +76,21 @@ } } + enum ContextKind { + ASSIGN("SAM s = #E;"), + METHOD("m(#E, i);"); + + String contextTemplate; + + ContextKind(String contextTemplate) { + this.contextTemplate = contextTemplate; + } + + String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) { + return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk)); + } + } + enum GenericKind { NONE(""), ONE(""), @@ -97,7 +112,10 @@ UBOUND_SIMPLE("A"), UNBOUND_GENERIC1("A"), UNBOUND_GENERIC2("A"), - UNBOUND_GENERIC3("A"); + UNBOUND_GENERIC3("A"), + UNBOUND_GENERIC4("A"), + NESTED_GENERIC1("A, A>"), + NESTED_GENERIC2("A,A>, A,A>>"); String qualifier; @@ -153,7 +171,9 @@ for (GenericKind gk : GenericKind.values()) { for (SubExprKind sk : SubExprKind.values()) { for (ExprKind ek : ExprKind.values()) { - new MethodReferenceParserTest(rk, qk, gk, sk, ek).run(comp, fm); + for (ContextKind ck : ContextKind.values()) { + new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck).run(comp, fm); + } } } } @@ -167,15 +187,17 @@ GenericKind gk; SubExprKind sk; ExprKind ek; + ContextKind ck; JavaSource source; DiagnosticChecker diagChecker; - MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek) { + MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek, ContextKind ck) { this.rk = rk; this.qk = qk; this.gk = gk; this.sk = sk; this.ek = ek; + this.ck = ck; this.source = new JavaSource(); this.diagChecker = new DiagnosticChecker(); } @@ -183,14 +205,16 @@ class JavaSource extends SimpleJavaFileObject { String template = "class Test {\n" + - " SAM s = #E;\n" + + " void test() {\n" + + " #C\n" + + " }" + "}"; String source; public JavaSource() { super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); - source = template.replaceAll("#E", ek.expressionString(rk, qk, gk, sk)); + source = template.replaceAll("#C", ck.contextString(ek, rk, qk, gk, sk)); } @Override