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

Side by Side Diff: mojo/public/tools/bindings/pylib/parse/mojo_lexer_unittest.py

Issue 226263002: Mojo: Move mojo/public/bindings to mojo/public/tools/bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import mojo_lexer 5 import mojo_lexer
6 import unittest 6 import unittest
7 7
8 # Try to load the ply module, if not, then assume it is in the third_party 8 # Try to load the ply module, if not, then assume it is in the third_party
9 # directory. 9 # directory.
10 try: 10 try:
11 # Disable lint check which fails to find the ply module. 11 # Disable lint check which fails to find the ply module.
12 # pylint: disable=F0401 12 # pylint: disable=F0401
13 from ply import lex 13 from ply import lex
14 except ImportError: 14 except ImportError:
15 # This assumes this file is in src/mojo/public/tools/bindings/pylib/parse/.
15 module_path, module_name = os.path.split(__file__) 16 module_path, module_name = os.path.split(__file__)
16 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir, 17 third_party = os.path.join(module_path, os.pardir, os.pardir, os.pardir,
17 os.pardir, os.pardir, 'third_party') 18 os.pardir, os.pardir, os.pardir, 'third_party')
18 sys.path.append(third_party) 19 sys.path.append(third_party)
19 # pylint: disable=F0401 20 # pylint: disable=F0401
20 from ply import lex 21 from ply import lex
21 22
22 23
23 # This (monkey-patching LexToken to make comparison value-based) is evil, but 24 # This (monkey-patching LexToken to make comparison value-based) is evil, but
24 # we'll do it anyway. (I'm pretty sure ply's lexer never cares about comparing 25 # we'll do it anyway. (I'm pretty sure ply's lexer never cares about comparing
25 # for object identity.) 26 # for object identity.)
26 def _LexTokenEq(self, other): 27 def _LexTokenEq(self, other):
27 return self.type == other.type and self.value == other.value and \ 28 return self.type == other.type and self.value == other.value and \
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 def _SingleTokenForInput(self, input): 151 def _SingleTokenForInput(self, input):
151 """Gets the single token for the given input string. (Raises an exception if 152 """Gets the single token for the given input string. (Raises an exception if
152 the input string does not result in exactly one token.)""" 153 the input string does not result in exactly one token.)"""
153 toks = self._TokensForInput(input) 154 toks = self._TokensForInput(input)
154 assert len(toks) == 1 155 assert len(toks) == 1
155 return toks[0] 156 return toks[0]
156 157
157 158
158 if __name__ == "__main__": 159 if __name__ == "__main__":
159 unittest.main() 160 unittest.main()
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/parse/mojo_lexer.py ('k') | mojo/public/tools/bindings/pylib/parse/mojo_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698