| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 def verify_miss(string, expected): | 97 def verify_miss(string, expected): |
| 98 verify(string, expected + [('MISS',)]) | 98 verify(string, expected + [('MISS',)]) |
| 99 def verify_hit(string, expected): | 99 def verify_hit(string, expected): |
| 100 verify(string, expected + [('TERMINATE',)]) | 100 verify(string, expected + [('TERMINATE',)]) |
| 101 (l, r) = left_action, right_action | 101 (l, r) = left_action, right_action |
| 102 verify_hit("left", [l]) | 102 verify_hit("left", [l]) |
| 103 verify_miss("lefta", [l]) | 103 verify_miss("lefta", [l]) |
| 104 verify_hit("leftrightleftright", [l, r, l, r]) | 104 verify_hit("leftrightleftright", [l, r, l, r]) |
| 105 verify_miss("leftrightleftrightx", [l, r, l, r]) | 105 verify_miss("leftrightleftrightx", [l, r, l, r]) |
| 106 | 106 |
| 107 def test_continue(self): | 107 def test_minimization(self): |
| 108 graph = NfaBuilder.cat_graphs([ | 108 for (regex, matches, not_matches) in self.__test_data: |
| 109 NfaBuilder.cat_graphs([ | 109 (nfa, dfa) = build_automata(regex) |
| 110 RegexParser.parse("ab"), | 110 dfa.minimize() |
| 111 NfaBuilder.add_continue(RegexParser.parse("cd"))]), | 111 |
| 112 RegexParser.parse("ef")]) | 112 |
| 113 nfa = NfaBuilder().nfa(graph) | |
| 114 self.assertFalse(nfa.matches("")) | |
| 115 self.assertTrue(nfa.matches("abcdef")) | |
| 116 self.assertTrue(nfa.matches("abcdabcdef")) | |
| OLD | NEW |