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
This commit is contained in:
parent
9d0ba7ae7f
commit
022d7a19d3
@ -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 class LambdaParserTest extends ComboInstance<LambdaParserTest> {
|
||||
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,21 +244,29 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
|
||||
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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
for (int i = lk.arity(); i < pks.length ; i++) {
|
||||
if (pks[i].ordinal() != 0) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user