2018-07-03 | Paul Boddie | file changeset files shortlog | Take advantage of context testing when acquiring functions for invocation. Since a context whose nature has been determined will have been tested, either as a consequence of deduction or at run-time, use of __get_function (which tests the context again) is unnecessary. |
paul@437 | 1 | from pyparser.automata import DFA, DEFAULT |
paul@437 | 2 | from pyparser.genpytokenize import output |
paul@437 | 3 | |
paul@437 | 4 | def test_states(): |
paul@437 | 5 | states = [{"\x00": 1}, {"\x01": 0}] |
paul@437 | 6 | d = DFA(states[:], [False, True]) |
paul@437 | 7 | assert output('test', DFA, d, states) == """\ |
paul@437 | 8 | accepts = [False, True] |
paul@437 | 9 | states = [ |
paul@437 | 10 | # 0 |
paul@437 | 11 | {'\\x00': 1}, |
paul@437 | 12 | # 1 |
paul@437 | 13 | {'\\x01': 0}, |
paul@437 | 14 | ] |
paul@437 | 15 | test = automata.pyparser.automata.DFA(states, accepts) |
paul@437 | 16 | """ |