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

Unified Diff: tools/lexer_generator/automata_test.py

Issue 77863004: Experimental parser: small cleanups (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month 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/automaton.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 6c45b9ed9628fc93d6c4fc6a722b8e0fd2803886..a81adb23a6e75b3f50bfb6b6c84fe389f3a0d017 100644
--- a/tools/lexer_generator/automata_test.py
+++ b/tools/lexer_generator/automata_test.py
@@ -32,20 +32,15 @@ from transition_keys import TransitionKey
from nfa_builder import NfaBuilder
from dfa import Dfa
-def dfa_from_nfa(nfa):
- (start_name, dfa_nodes) = nfa.compute_dfa()
- return Dfa(start_name, dfa_nodes)
-
-def build_automata(string):
- nfa = NfaBuilder().nfa(RegexParser.parse(string))
- dfa = dfa_from_nfa(nfa)
- return (nfa, dfa, dfa.minimize())
-
-def simple_action(string):
- return Action(None, (string, None))
-
class AutomataTestCase(unittest.TestCase):
+ @staticmethod
+ def __build_automata(string):
+ nfa = NfaBuilder().nfa(RegexParser.parse(string))
+ (start_name, dfa_nodes) = nfa.compute_dfa()
+ dfa = Dfa(start_name, dfa_nodes)
+ return (nfa, dfa, dfa.minimize())
+
# (pattern, should match, should not match)
__test_data = [
("a", ["a"], ["b", ""]),
@@ -71,7 +66,7 @@ class AutomataTestCase(unittest.TestCase):
def test_matches(self):
for (regex, matches, not_matches) in self.__test_data:
- automata = build_automata(regex)
+ automata = self.__build_automata(regex)
for string in matches:
for automaton in automata:
self.assertTrue(automaton.matches(string))
@@ -81,7 +76,7 @@ class AutomataTestCase(unittest.TestCase):
def test_can_construct_dot(self):
for (regex, matches, not_matches) in self.__test_data:
- for automaton in build_automata(regex):
+ for automaton in self.__build_automata(regex):
automaton.to_dot()
def test_minimization(self):
@@ -100,4 +95,3 @@ class AutomataTestCase(unittest.TestCase):
mdfa = Dfa('S_0', mapping).minimize()
self.assertEqual(3, mdfa.node_count())
-
« no previous file with comments | « no previous file | tools/lexer_generator/automaton.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698