1.1 --- a/test/tools/javac/lambda/MethodReferenceParserTest.java Fri Dec 16 16:41:00 2011 -0800 1.2 +++ b/test/tools/javac/lambda/MethodReferenceParserTest.java Mon Dec 19 12:07:07 2011 +0000 1.3 @@ -24,7 +24,6 @@ 1.4 /* 1.5 * @test 1.6 * @bug 7115052 1.7 - * @ignore 7120266 1.8 * @summary Add parser support for method references 1.9 */ 1.10 1.11 @@ -45,6 +44,7 @@ 1.12 enum ReferenceKind { 1.13 METHOD_REF("#Q##Gm"), 1.14 CONSTRUCTOR_REF("#Q##Gnew"), 1.15 + FALSE_REF("min < max"), 1.16 ERR_SUPER("#Q##Gsuper"), 1.17 ERR_METH0("#Q##Gm()"), 1.18 ERR_METH1("#Q##Gm(X)"), 1.19 @@ -76,6 +76,21 @@ 1.20 } 1.21 } 1.22 1.23 + enum ContextKind { 1.24 + ASSIGN("SAM s = #E;"), 1.25 + METHOD("m(#E, i);"); 1.26 + 1.27 + String contextTemplate; 1.28 + 1.29 + ContextKind(String contextTemplate) { 1.30 + this.contextTemplate = contextTemplate; 1.31 + } 1.32 + 1.33 + String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) { 1.34 + return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk)); 1.35 + } 1.36 + } 1.37 + 1.38 enum GenericKind { 1.39 NONE(""), 1.40 ONE("<X>"), 1.41 @@ -97,7 +112,10 @@ 1.42 UBOUND_SIMPLE("A"), 1.43 UNBOUND_GENERIC1("A<X>"), 1.44 UNBOUND_GENERIC2("A<X, Y>"), 1.45 - UNBOUND_GENERIC3("A<? extends X, ? super Y>"); 1.46 + UNBOUND_GENERIC3("A<? extends X, ? super Y>"), 1.47 + UNBOUND_GENERIC4("A<int[], short[][]>"), 1.48 + NESTED_GENERIC1("A<A<X,Y>, A<X,Y>>"), 1.49 + NESTED_GENERIC2("A<A<A<X,Y>,A<X,Y>>, A<A<X,Y>,A<X,Y>>>"); 1.50 1.51 String qualifier; 1.52 1.53 @@ -153,7 +171,9 @@ 1.54 for (GenericKind gk : GenericKind.values()) { 1.55 for (SubExprKind sk : SubExprKind.values()) { 1.56 for (ExprKind ek : ExprKind.values()) { 1.57 - new MethodReferenceParserTest(rk, qk, gk, sk, ek).run(comp, fm); 1.58 + for (ContextKind ck : ContextKind.values()) { 1.59 + new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck).run(comp, fm); 1.60 + } 1.61 } 1.62 } 1.63 } 1.64 @@ -167,15 +187,17 @@ 1.65 GenericKind gk; 1.66 SubExprKind sk; 1.67 ExprKind ek; 1.68 + ContextKind ck; 1.69 JavaSource source; 1.70 DiagnosticChecker diagChecker; 1.71 1.72 - MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek) { 1.73 + MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek, ContextKind ck) { 1.74 this.rk = rk; 1.75 this.qk = qk; 1.76 this.gk = gk; 1.77 this.sk = sk; 1.78 this.ek = ek; 1.79 + this.ck = ck; 1.80 this.source = new JavaSource(); 1.81 this.diagChecker = new DiagnosticChecker(); 1.82 } 1.83 @@ -183,14 +205,16 @@ 1.84 class JavaSource extends SimpleJavaFileObject { 1.85 1.86 String template = "class Test {\n" + 1.87 - " SAM s = #E;\n" + 1.88 + " void test() {\n" + 1.89 + " #C\n" + 1.90 + " }" + 1.91 "}"; 1.92 1.93 String source; 1.94 1.95 public JavaSource() { 1.96 super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); 1.97 - source = template.replaceAll("#E", ek.expressionString(rk, qk, gk, sk)); 1.98 + source = template.replaceAll("#C", ck.contextString(ek, rk, qk, gk, sk)); 1.99 } 1.100 1.101 @Override