| OLD | NEW |
| 1 # Copyright 2013 the V8 project authors. All rights reserved. | 1 # Copyright 2013 the V8 project authors. All rights reserved. |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 automaton.to_dot() | 84 automaton.to_dot() |
| 85 | 85 |
| 86 def test_minimization(self): | 86 def test_minimization(self): |
| 87 encoding = self.__encoding | 87 encoding = self.__encoding |
| 88 def empty_node(): | 88 def empty_node(): |
| 89 return { | 89 return { |
| 90 'transitions' : {}, | 90 'transitions' : {}, |
| 91 'terminal' : False, | 91 'terminal' : False, |
| 92 'action' : Action.empty_action() } | 92 'action' : Action.empty_action() } |
| 93 mapping = { k : empty_node() for k in ['S_0', 'S_1', 'S_2', 'S_3'] } | 93 mapping = { k : empty_node() for k in ['S_0', 'S_1', 'S_2', 'S_3'] } |
| 94 key_a = TransitionKey.single_char(encoding, 'a') | 94 key_a = TransitionKey.single_char(encoding, ord('a')) |
| 95 key_b = TransitionKey.single_char(encoding, 'b') | 95 key_b = TransitionKey.single_char(encoding, ord('b')) |
| 96 key_c = TransitionKey.single_char(encoding, 'c') | 96 key_c = TransitionKey.single_char(encoding, ord('c')) |
| 97 | 97 |
| 98 mapping['S_0']['transitions'][key_a] = 'S_1' | 98 mapping['S_0']['transitions'][key_a] = 'S_1' |
| 99 mapping['S_0']['transitions'][key_b] = 'S_2' | 99 mapping['S_0']['transitions'][key_b] = 'S_2' |
| 100 mapping['S_1']['transitions'][key_c] = 'S_3' | 100 mapping['S_1']['transitions'][key_c] = 'S_3' |
| 101 mapping['S_2']['transitions'][key_c] = 'S_3' | 101 mapping['S_2']['transitions'][key_c] = 'S_3' |
| 102 mapping['S_3']['terminal'] = True | 102 mapping['S_3']['terminal'] = True |
| 103 | 103 |
| 104 mdfa = Dfa(encoding, 'S_0', mapping).minimize() | 104 mdfa = Dfa(encoding, 'S_0', mapping).minimize() |
| 105 self.assertEqual(3, mdfa.node_count()) | 105 self.assertEqual(3, mdfa.node_count()) |
| OLD | NEW |