Skip to content
Permalink
Browse files
8236108: tools/javac/lambda/LambdaParserTest.java timed out
The patch filters redundant or non-sense combinations of lambdas and it reduces the number of performed sub-tests.

Reviewed-by: vromero
  • Loading branch information
asotona committed Jun 9, 2020
1 parent 9d0ba7a commit 022d7a19d37836bbc101c94c84f81520385b824f
Showing 1 changed file with 22 additions and 15 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -229,14 +229,13 @@ public String expand(String optParameter) {
public static void main(String... args) throws Exception {
new ComboTestHelper<LambdaParserTest>()
.withFilter(LambdaParserTest::redundantTestFilter)
.withFilter(LambdaParserTest::badImplicitFilter)
.withDimension("SOURCE", (x, sk) -> x.sk = sk, SourceKind.values())
.withDimension("LAMBDA", (x, lk) -> x.lk = lk, LambdaKind.values())
.withDimension("NAME", (x, name) -> x.pn = name, LambdaParameterName.values())
.withArrayDimension("TYPE", (x, type, idx) -> x.pks[idx] = type, 2, LambdaParameterKind.values())
.withArrayDimension("MOD", (x, mod, idx) -> x.mks[idx] = mod, 2, ModifierKind.values())
.withDimension("EXPR", ExprKind.values())
.withDimension("SUBEXPR", SubExprKind.values())
.withDimension("EXPR", (x, exp) -> x.exp = exp, ExprKind.values())
.withDimension("SUBEXPR", (x, sub) -> x.sub = sub, SubExprKind.values())
.run(LambdaParserTest::new);
}

@@ -245,22 +244,30 @@ public static void main(String... args) throws Exception {
LambdaKind lk;
LambdaParameterName pn;
SourceKind sk;

boolean badImplicitFilter() {
return !(mks[0] != ModifierKind.NONE && lk.isShort());
}
ExprKind exp;
SubExprKind sub;

boolean redundantTestFilter() {
for (int i = lk.arity(); i < mks.length ; i++) {
if (mks[i].ordinal() != 0) {
return false;
if (sub == SubExprKind.NONE) {
switch (exp) {
//followings combinations with empty sub-expressions produces the same source
case SINGLE_PAREN2, DOUBLE_PAREN2, DOUBLE_PAREN3: return false;
}
}
for (int i = lk.arity(); i < pks.length ; i++) {
if (pks[i].ordinal() != 0) {
return false;
} else {
switch (lk) {
//any non-empty subexpression does not combine with lambda statements
case NILARY_STMT, ONEARY_SHORT_STMT, ONEARY_STMT, TWOARY_STMT: return false;
}
}
switch (lk) {
//parameters not present in the expression are redundant
case NILARY_EXPR, NILARY_STMT:
if (pn.ordinal() != 0) return false;
case ONEARY_SHORT_EXPR, ONEARY_SHORT_STMT:
if (pks[0].ordinal() != 0 || mks[0].ordinal() != 0) return false;
case ONEARY_EXPR, ONEARY_STMT :
if (pks[1].ordinal() != 0 || mks[1].ordinal() != 0) return false;
}
return true;
}

0 comments on commit 022d7a1

Please sign in to comment.