def test_is_dead_with_cache_reuse(): dfa = ConcreteDFA([{0: i + 1, 1: 11} for i in range(10)] + [{}, {}], {10}) for n in range(10, -1, -1): assert not dfa.is_dead(n)
def test_dfa_with_cached_dead(): dfa = ConcreteDFA([[{0: 1, 1: 2}], [], []], {2}) assert dfa.is_dead(1) assert dfa.is_dead(0)
def test_dead_nodes(order): dfa = ConcreteDFA([{0: 1, 1: 2}, {}, {}], {2}) for i in order: assert dfa.is_dead(i) == (i == 1)
def test_max_length_of_long_dfa(n): dfa = ConcreteDFA([{0: i + 1} for i in range(n)] + [{}], {n}) assert not dfa.is_dead(dfa.start) assert dfa.max_length(dfa.start) == n