mirror of https://github.com/apache/lucene.git
just retry if automaton is too complex to determinize
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1700444 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1017a685b2
commit
6d5b236dea
|
@ -257,18 +257,25 @@ public class AutomatonTestUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/** return a random NFA/DFA for testing */
|
||||
public static Automaton randomAutomaton(Random random) {
|
||||
// get two random Automata from regexps
|
||||
private static Automaton randomSingleAutomaton(Random random) {
|
||||
while (true) {
|
||||
try {
|
||||
Automaton a1 = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton();
|
||||
if (random.nextBoolean()) {
|
||||
a1 = Operations.complement(a1, DEFAULT_MAX_DETERMINIZED_STATES);
|
||||
}
|
||||
|
||||
Automaton a2 = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton();
|
||||
if (random.nextBoolean()) {
|
||||
a2 = Operations.complement(a2, DEFAULT_MAX_DETERMINIZED_STATES);
|
||||
return a1;
|
||||
} catch (TooComplexToDeterminizeException tctde) {
|
||||
// This can (rarely) happen if the random regexp is too hard; just try again...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** return a random NFA/DFA for testing */
|
||||
public static Automaton randomAutomaton(Random random) {
|
||||
// get two random Automata from regexps
|
||||
Automaton a1 = randomSingleAutomaton(random);
|
||||
Automaton a2 = randomSingleAutomaton(random);
|
||||
|
||||
// combine them in random ways
|
||||
switch (random.nextInt(4)) {
|
||||
|
|
Loading…
Reference in New Issue