remove dead states after union(), just like intersection() and complement() do

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1607139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-07-01 16:52:20 +00:00
parent 5c75969c04
commit 33bf336cd4
2 changed files with 9 additions and 2 deletions

View File

@ -505,7 +505,7 @@ final public class Operations {
result.finishState();
return result;
return removeDeadStates(result);
}
// Simple custom ArrayList<Transition>

View File

@ -34,7 +34,14 @@ public class TestOperations extends LuceneTestCase {
Collections.sort(strings);
Automaton union = Automata.makeStringUnion(strings);
assertTrue(union.isDeterministic());
assertTrue(Operations.sameLanguage(union, naiveUnion(strings)));
assertFalse(Operations.hasDeadStatesFromInitial(union));
Automaton naiveUnion = naiveUnion(strings);
assertTrue(naiveUnion.isDeterministic());
assertFalse(Operations.hasDeadStatesFromInitial(naiveUnion));
assertTrue(Operations.sameLanguage(union, naiveUnion));
}
private static Automaton naiveUnion(List<BytesRef> strings) {