예제 #1
0
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)
예제 #2
0
def test_dfa_with_cached_dead():
    dfa = ConcreteDFA([[{0: 1, 1: 2}], [], []], {2})

    assert dfa.is_dead(1)
    assert dfa.is_dead(0)
예제 #3
0
def test_dead_nodes(order):
    dfa = ConcreteDFA([{0: 1, 1: 2}, {}, {}], {2})
    for i in order:
        assert dfa.is_dead(i) == (i == 1)
예제 #4
0
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