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

Unified Diff: tools/lexer_generator/action_test.py

Issue 77533003: Experimental parser: remove action tests (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/lexer_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/action_test.py
diff --git a/tools/lexer_generator/action_test.py b/tools/lexer_generator/action_test.py
deleted file mode 100644
index b5f8a86570eca7115e4971d4f969972611c914f5..0000000000000000000000000000000000000000
--- a/tools/lexer_generator/action_test.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright 2013 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import unittest
-from automaton import Action
-from rule_parser import RuleProcessor
-from nfa_builder import NfaBuilder
-from dfa import Dfa
-
-def process_rules(rules):
- rule_map = {}
- for name, automata in RuleProcessor.parse(rules).automata_iter():
- rule_map[name] = automata
- return rule_map
-
-class ActionTestCase(unittest.TestCase):
-
- def __verify_last_action(self, automata, string, expected_code):
- expected_code = (expected_code, None)
- for automaton in [automata.dfa(), automata.minimal_dfa()]:
- actions = list(automaton.collect_actions(string))
- self.assertEqual(actions[-1], Dfa.terminal_action())
- self.assertEqual(actions[-2].match_action(), expected_code)
-
- def test_action_precedence(self):
- rules = '''<<default>>
- "key" <|KEYWORD|>
- /[a-z]+/ <|ID|>'''
- automata_for_conditions = process_rules(rules)
- self.assertEqual(len(automata_for_conditions), 1)
- self.assertTrue('default' in automata_for_conditions)
- automata = automata_for_conditions['default']
-
- self.__verify_last_action(automata, 'foo', 'ID')
- self.__verify_last_action(automata, 'key', 'KEYWORD')
- self.__verify_last_action(automata, 'k', 'ID')
- self.__verify_last_action(automata, 'ke', 'ID')
- self.__verify_last_action(automata, 'keys', 'ID')
-
- def test_wrong_action_precedence(self):
- rules = '''<<default>>
- /[a-z]+/ <|ID|>
- "key" <|KEYWORD|>'''
- automata_for_conditions = process_rules(rules)
- self.assertEqual(len(automata_for_conditions), 1)
- self.assertTrue('default' in automata_for_conditions)
- automata = automata_for_conditions['default']
-
- # The keyword is not recognized because of the rule preference order (ID
- # is preferred over KEYWORD).
- self.__verify_last_action(automata, 'foo', 'ID')
- self.__verify_last_action(automata, 'key', 'ID')
« no previous file with comments | « no previous file | tools/lexer_generator/lexer_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698