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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 self.assertEquals(self._SingleTokenForInput("123.456"), | 128 self.assertEquals(self._SingleTokenForInput("123.456"), |
129 _MakeLexToken("FLOAT_CONST", "123.456")) | 129 _MakeLexToken("FLOAT_CONST", "123.456")) |
130 self.assertEquals(self._SingleTokenForInput("\"hello\""), | 130 self.assertEquals(self._SingleTokenForInput("\"hello\""), |
131 _MakeLexToken("STRING_LITERAL", "\"hello\"")) | 131 _MakeLexToken("STRING_LITERAL", "\"hello\"")) |
132 self.assertEquals(self._SingleTokenForInput("+"), | 132 self.assertEquals(self._SingleTokenForInput("+"), |
133 _MakeLexToken("PLUS", "+")) | 133 _MakeLexToken("PLUS", "+")) |
134 self.assertEquals(self._SingleTokenForInput("-"), | 134 self.assertEquals(self._SingleTokenForInput("-"), |
135 _MakeLexToken("MINUS", "-")) | 135 _MakeLexToken("MINUS", "-")) |
136 self.assertEquals(self._SingleTokenForInput("&"), | 136 self.assertEquals(self._SingleTokenForInput("&"), |
137 _MakeLexToken("AMP", "&")) | 137 _MakeLexToken("AMP", "&")) |
| 138 self.assertEquals(self._SingleTokenForInput("?"), |
| 139 _MakeLexToken("QSTN", "?")) |
138 self.assertEquals(self._SingleTokenForInput("="), | 140 self.assertEquals(self._SingleTokenForInput("="), |
139 _MakeLexToken("EQUALS", "=")) | 141 _MakeLexToken("EQUALS", "=")) |
140 self.assertEquals(self._SingleTokenForInput("=>"), | 142 self.assertEquals(self._SingleTokenForInput("=>"), |
141 _MakeLexToken("RESPONSE", "=>")) | 143 _MakeLexToken("RESPONSE", "=>")) |
142 self.assertEquals(self._SingleTokenForInput("("), | 144 self.assertEquals(self._SingleTokenForInput("("), |
143 _MakeLexToken("LPAREN", "(")) | 145 _MakeLexToken("LPAREN", "(")) |
144 self.assertEquals(self._SingleTokenForInput(")"), | 146 self.assertEquals(self._SingleTokenForInput(")"), |
145 _MakeLexToken("RPAREN", ")")) | 147 _MakeLexToken("RPAREN", ")")) |
146 self.assertEquals(self._SingleTokenForInput("["), | 148 self.assertEquals(self._SingleTokenForInput("["), |
147 _MakeLexToken("LBRACKET", "[")) | 149 _MakeLexToken("LBRACKET", "[")) |
(...skipping 28 matching lines...) Expand all Loading... |
176 def _SingleTokenForInput(self, input_string): | 178 def _SingleTokenForInput(self, input_string): |
177 """Gets the single token for the given input string. (Raises an exception if | 179 """Gets the single token for the given input string. (Raises an exception if |
178 the input string does not result in exactly one token.)""" | 180 the input string does not result in exactly one token.)""" |
179 toks = self._TokensForInput(input_string) | 181 toks = self._TokensForInput(input_string) |
180 assert len(toks) == 1 | 182 assert len(toks) == 1 |
181 return toks[0] | 183 return toks[0] |
182 | 184 |
183 | 185 |
184 if __name__ == "__main__": | 186 if __name__ == "__main__": |
185 unittest.main() | 187 unittest.main() |
OLD | NEW |