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 def _GetDirAbove(dirname): | 10 def _GetDirAbove(dirname): |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 # Keywords tested in |testValidKeywords|. | 117 # Keywords tested in |testValidKeywords|. |
118 # NAME tested in |testValidIdentifiers|. | 118 # NAME tested in |testValidIdentifiers|. |
119 self.assertEquals(self._SingleTokenForInput("@123"), | 119 self.assertEquals(self._SingleTokenForInput("@123"), |
120 _MakeLexToken("ORDINAL", "@123")) | 120 _MakeLexToken("ORDINAL", "@123")) |
121 self.assertEquals(self._SingleTokenForInput("456"), | 121 self.assertEquals(self._SingleTokenForInput("456"), |
122 _MakeLexToken("INT_CONST_DEC", "456")) | 122 _MakeLexToken("INT_CONST_DEC", "456")) |
123 self.assertEquals(self._SingleTokenForInput("0x01aB2eF3"), | 123 self.assertEquals(self._SingleTokenForInput("0x01aB2eF3"), |
124 _MakeLexToken("INT_CONST_HEX", "0x01aB2eF3")) | 124 _MakeLexToken("INT_CONST_HEX", "0x01aB2eF3")) |
125 self.assertEquals(self._SingleTokenForInput("123.456"), | 125 self.assertEquals(self._SingleTokenForInput("123.456"), |
126 _MakeLexToken("FLOAT_CONST", "123.456")) | 126 _MakeLexToken("FLOAT_CONST", "123.456")) |
| 127 self.assertEquals(self._SingleTokenForInput("Inf"), |
| 128 _MakeLexToken("FLOAT_CONST", "Inf")) |
| 129 self.assertEquals(self._SingleTokenForInput("+Inf"), |
| 130 _MakeLexToken("FLOAT_CONST", "+Inf")) |
| 131 self.assertEquals(self._SingleTokenForInput("-Inf"), |
| 132 _MakeLexToken("FLOAT_CONST", "-Inf")) |
| 133 self.assertEquals(self._SingleTokenForInput("NaN"), |
| 134 _MakeLexToken("FLOAT_CONST", "NaN")) |
127 self.assertEquals(self._SingleTokenForInput("\"hello\""), | 135 self.assertEquals(self._SingleTokenForInput("\"hello\""), |
128 _MakeLexToken("STRING_LITERAL", "\"hello\"")) | 136 _MakeLexToken("STRING_LITERAL", "\"hello\"")) |
129 self.assertEquals(self._SingleTokenForInput("+"), | 137 self.assertEquals(self._SingleTokenForInput("+"), |
130 _MakeLexToken("PLUS", "+")) | 138 _MakeLexToken("PLUS", "+")) |
131 self.assertEquals(self._SingleTokenForInput("-"), | 139 self.assertEquals(self._SingleTokenForInput("-"), |
132 _MakeLexToken("MINUS", "-")) | 140 _MakeLexToken("MINUS", "-")) |
133 self.assertEquals(self._SingleTokenForInput("&"), | 141 self.assertEquals(self._SingleTokenForInput("&"), |
134 _MakeLexToken("AMP", "&")) | 142 _MakeLexToken("AMP", "&")) |
135 self.assertEquals(self._SingleTokenForInput("?"), | 143 self.assertEquals(self._SingleTokenForInput("?"), |
136 _MakeLexToken("QSTN", "?")) | 144 _MakeLexToken("QSTN", "?")) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 def _SingleTokenForInput(self, input_string): | 183 def _SingleTokenForInput(self, input_string): |
176 """Gets the single token for the given input string. (Raises an exception if | 184 """Gets the single token for the given input string. (Raises an exception if |
177 the input string does not result in exactly one token.)""" | 185 the input string does not result in exactly one token.)""" |
178 toks = self._TokensForInput(input_string) | 186 toks = self._TokensForInput(input_string) |
179 assert len(toks) == 1 | 187 assert len(toks) == 1 |
180 return toks[0] | 188 return toks[0] |
181 | 189 |
182 | 190 |
183 if __name__ == "__main__": | 191 if __name__ == "__main__": |
184 unittest.main() | 192 unittest.main() |
OLD | NEW |