LUCENE-10010: fix TestMockAnalyzer to determinize

Test would randomly fail, if RegExp parsing returned an NFA, because it
wasn't explicitly determinizing itself.

This is a bit of a trap in RegExp, it calls minimize()-as-it-parses,
so at least most of the time, it returns a DFA. This may be
unnecessary...
This commit is contained in:
Robert Muir 2021-12-03 20:44:45 -05:00
parent c8f5b9127d
commit a39337e595
No known key found for this signature in database
GPG Key ID: 817AE1DD322D7ECA
1 changed files with 6 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.automaton.Automata;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.Operations;
@ -221,8 +222,11 @@ public class TestMockAnalyzer extends BaseTokenStreamTestCase {
public void testRandomRegexps() throws Exception {
int iters = TEST_NIGHTLY ? atLeast(30) : atLeast(1);
for (int i = 0; i < iters; i++) {
final CharacterRunAutomaton dfa =
new CharacterRunAutomaton(AutomatonTestUtil.randomAutomaton(random()));
Automaton automaton =
Operations.determinize(
AutomatonTestUtil.randomAutomaton(random()),
Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);
final CharacterRunAutomaton dfa = new CharacterRunAutomaton(automaton);
final boolean lowercase = random().nextBoolean();
final int limit = TestUtil.nextInt(random(), 0, 500);
Analyzer a =