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

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

Issue 295773002: Mojo: Mojom: Make specialized handle types (e.g., message_pipe) not keywords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 7 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 imp 5 import imp
6 import os.path 6 import os.path
7 import sys 7 import sys
8 import unittest 8 import unittest
9 9
10 # Disable lint check for finding modules: 10 # Disable lint check for finding modules:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 def __init__(self, *args, **kwargs): 61 def __init__(self, *args, **kwargs):
62 unittest.TestCase.__init__(self, *args, **kwargs) 62 unittest.TestCase.__init__(self, *args, **kwargs)
63 # Clone all lexer instances from this one, since making a lexer is slow. 63 # Clone all lexer instances from this one, since making a lexer is slow.
64 self._zygote_lexer = lex.lex(mojom.parse.lexer.Lexer("my_file.mojom")) 64 self._zygote_lexer = lex.lex(mojom.parse.lexer.Lexer("my_file.mojom"))
65 65
66 def testValidKeywords(self): 66 def testValidKeywords(self):
67 """Tests valid keywords.""" 67 """Tests valid keywords."""
68 self.assertEquals(self._SingleTokenForInput("handle"), 68 self.assertEquals(self._SingleTokenForInput("handle"),
69 _MakeLexTokenForKeyword("handle")) 69 _MakeLexTokenForKeyword("handle"))
70 self.assertEquals(self._SingleTokenForInput("data_pipe_consumer"),
71 _MakeLexTokenForKeyword("data_pipe_consumer"))
72 self.assertEquals(self._SingleTokenForInput("data_pipe_producer"),
73 _MakeLexTokenForKeyword("data_pipe_producer"))
74 self.assertEquals(self._SingleTokenForInput("message_pipe"),
75 _MakeLexTokenForKeyword("message_pipe"))
76 self.assertEquals(self._SingleTokenForInput("import"), 70 self.assertEquals(self._SingleTokenForInput("import"),
77 _MakeLexTokenForKeyword("import")) 71 _MakeLexTokenForKeyword("import"))
78 self.assertEquals(self._SingleTokenForInput("module"), 72 self.assertEquals(self._SingleTokenForInput("module"),
79 _MakeLexTokenForKeyword("module")) 73 _MakeLexTokenForKeyword("module"))
80 self.assertEquals(self._SingleTokenForInput("struct"), 74 self.assertEquals(self._SingleTokenForInput("struct"),
81 _MakeLexTokenForKeyword("struct")) 75 _MakeLexTokenForKeyword("struct"))
82 self.assertEquals(self._SingleTokenForInput("interface"), 76 self.assertEquals(self._SingleTokenForInput("interface"),
83 _MakeLexTokenForKeyword("interface")) 77 _MakeLexTokenForKeyword("interface"))
84 self.assertEquals(self._SingleTokenForInput("enum"), 78 self.assertEquals(self._SingleTokenForInput("enum"),
85 _MakeLexTokenForKeyword("enum")) 79 _MakeLexTokenForKeyword("enum"))
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 def _SingleTokenForInput(self, input_string): 186 def _SingleTokenForInput(self, input_string):
193 """Gets the single token for the given input string. (Raises an exception if 187 """Gets the single token for the given input string. (Raises an exception if
194 the input string does not result in exactly one token.)""" 188 the input string does not result in exactly one token.)"""
195 toks = self._TokensForInput(input_string) 189 toks = self._TokensForInput(input_string)
196 assert len(toks) == 1 190 assert len(toks) == 1
197 return toks[0] 191 return toks[0]
198 192
199 193
200 if __name__ == "__main__": 194 if __name__ == "__main__":
201 unittest.main() 195 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698