OLD | NEW |
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 Loading... |
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 Loading... |
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() |
OLD | NEW |