Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: tools/lexer_generator/automata_test.py

Issue 54533002: Experimental parser: more tests, better key logic (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/lexer_generator/nfa.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « no previous file | tools/lexer_generator/nfa.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698