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 | |
paul@437 | 3 | def test_states(): |
paul@437 | 4 | d = DFA([{"\x00": 1}, {"\x01": 0}], [False, True]) |
paul@437 | 5 | assert d.states == "\x01\xff\xff\x00" |
paul@437 | 6 | assert d.defaults == "\xff\xff" |
paul@437 | 7 | assert d.max_char == 2 |
paul@437 | 8 | |
paul@437 | 9 | d = DFA([{"\x00": 1}, {DEFAULT: 0}], [False, True]) |
paul@437 | 10 | assert d.states == "\x01\x00" |
paul@437 | 11 | assert d.defaults == "\xff\x00" |
paul@437 | 12 | assert d.max_char == 1 |