def test_mixed_dfa_initialization(): d = ConcreteDFA([[(2, 1)], [(0, 5, 2)], {4: 0, 3: 1}], {0}) assert d.transition(0, 2) == 1 assert d.transition(0, 3) == DEAD for n in range(6): assert d.transition(1, n) == 2 assert d.transition(1, 6) == DEAD assert d.transition(2, 4) == 0 assert d.transition(2, 3) == 1 assert d.transition(2, 5) == DEAD
def test_converts_long_tables_to_dicts(): dfa = ConcreteDFA([[(0, 0), (1, 1), (2, 2), (3, 1), (4, 0), (7, 10, 1)], [(0, 0)], []], {2}) assert dfa.transition(0, 2) == 2 assert dfa.transition(1, 0) == 0 assert isinstance(dfa._ConcreteDFA__transitions[0], dict) assert isinstance(dfa._ConcreteDFA__transitions[1], list)
def test_can_transition_from_dead(): dfa = ConcreteDFA([{}], {0}) assert dfa.transition(DEAD, 0) == DEAD