| Index: tools/lexer_generator/automata_test.py
|
| diff --git a/tools/lexer_generator/automata_test.py b/tools/lexer_generator/automata_test.py
|
| index 42346a9100d0e3c8facf7b569701e030288b1e49..ca4abe37f02d5de3486e9247e8c75bad16b94aee 100644
|
| --- a/tools/lexer_generator/automata_test.py
|
| +++ b/tools/lexer_generator/automata_test.py
|
| @@ -43,16 +43,22 @@ class AutomataTestCase(unittest.TestCase):
|
|
|
| # (pattern, should match, shouldn't match)
|
| __test_data = [
|
| - ("a", ["a"], ["b"]),
|
| - ("ab", ["ab"], ["bb"]),
|
| - ("a+b", ["ab", "aab", "aaab"], ["a", "b"]),
|
| - ("a?b", ["ab", "b"], ["a", "c"]),
|
| - ("a*b", ["ab", "aaab", "b"], ["a", "c"]),
|
| - ("a|b", ["a", "b"], ["ab", "c"]),
|
| + ("a", ["a"], ["b", ""]),
|
| + ("ab", ["ab"], ["bb", ""]),
|
| + ("a+b", ["ab", "aab", "aaab"], ["a", "b", ""]),
|
| + ("a?b", ["ab", "b"], ["a", "c", ""]),
|
| + ("a*b", ["ab", "aaab", "b"], ["a", "c", ""]),
|
| + ("a|b", ["a", "b"], ["ab", "c", ""]),
|
| + (".", ["a", "b"], ["", "aa"]),
|
| + (".*", ["", "a", "abcaabbcc"], []),
|
| + ("a.b", ["aab", "abb", "acb"], ["ab", ""]),
|
| + # ("a.?b", ["aab", "abb", "acb", "ab"], ["aaab", ""]),
|
| + # ("a.+b", ["aab", "abb", "acb", "ab"], ["aaab", ""]),
|
| + (".|.", ["a", "b"], ["aa", ""]),
|
| ]
|
|
|
| def test_matches(self):
|
| - for (regex, matches, not_matches) in AutomataTestCase.__test_data:
|
| + for (regex, matches, not_matches) in self.__test_data:
|
| (nfa, dfa) = build_automata(regex)
|
| for string in matches:
|
| self.assertTrue(nfa.matches(string))
|
| @@ -61,5 +67,11 @@ class AutomataTestCase(unittest.TestCase):
|
| self.assertFalse(nfa.matches(string))
|
| self.assertFalse(dfa.matches(string))
|
|
|
| + def test_can_construct_dot(self):
|
| + for (regex, matches, not_matches) in self.__test_data:
|
| + (nfa, dfa) = build_automata(regex)
|
| + nfa.to_dot()
|
| + dfa.to_dot()
|
| +
|
| if __name__ == '__main__':
|
| unittest.main()
|
|
|