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("double.INFINITY"), |
| 128 _MakeLexToken("FLOAT_BUILTIN", "double.INFINITY")) |
| 129 self.assertEquals(self._SingleTokenForInput("double.NEGATIVE_INFINITY"), |
| 130 _MakeLexToken("FLOAT_BUILTIN", |
| 131 "double.NEGATIVE_INFINITY")) |
| 132 self.assertEquals(self._SingleTokenForInput("double.NAN"), |
| 133 _MakeLexToken("FLOAT_BUILTIN", "double.NAN")) |
| 134 self.assertEquals(self._SingleTokenForInput("float.INFINITY"), |
| 135 _MakeLexToken("FLOAT_BUILTIN", "float.INFINITY")) |
| 136 self.assertEquals(self._SingleTokenForInput("float.NEGATIVE_INFINITY"), |
| 137 _MakeLexToken("FLOAT_BUILTIN", "float.NEGATIVE_INFINITY")) |
| 138 self.assertEquals(self._SingleTokenForInput("float.NAN"), |
| 139 _MakeLexToken("FLOAT_BUILTIN", "float.NAN")) |
127 self.assertEquals(self._SingleTokenForInput("\"hello\""), | 140 self.assertEquals(self._SingleTokenForInput("\"hello\""), |
128 _MakeLexToken("STRING_LITERAL", "\"hello\"")) | 141 _MakeLexToken("STRING_LITERAL", "\"hello\"")) |
129 self.assertEquals(self._SingleTokenForInput("+"), | 142 self.assertEquals(self._SingleTokenForInput("+"), |
130 _MakeLexToken("PLUS", "+")) | 143 _MakeLexToken("PLUS", "+")) |
131 self.assertEquals(self._SingleTokenForInput("-"), | 144 self.assertEquals(self._SingleTokenForInput("-"), |
132 _MakeLexToken("MINUS", "-")) | 145 _MakeLexToken("MINUS", "-")) |
133 self.assertEquals(self._SingleTokenForInput("&"), | 146 self.assertEquals(self._SingleTokenForInput("&"), |
134 _MakeLexToken("AMP", "&")) | 147 _MakeLexToken("AMP", "&")) |
135 self.assertEquals(self._SingleTokenForInput("?"), | 148 self.assertEquals(self._SingleTokenForInput("?"), |
136 _MakeLexToken("QSTN", "?")) | 149 _MakeLexToken("QSTN", "?")) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 def _SingleTokenForInput(self, input_string): | 188 def _SingleTokenForInput(self, input_string): |
176 """Gets the single token for the given input string. (Raises an exception if | 189 """Gets the single token for the given input string. (Raises an exception if |
177 the input string does not result in exactly one token.)""" | 190 the input string does not result in exactly one token.)""" |
178 toks = self._TokensForInput(input_string) | 191 toks = self._TokensForInput(input_string) |
179 assert len(toks) == 1 | 192 assert len(toks) == 1 |
180 return toks[0] | 193 return toks[0] |
181 | 194 |
182 | 195 |
183 if __name__ == "__main__": | 196 if __name__ == "__main__": |
184 unittest.main() | 197 unittest.main() |
OLD | NEW |