Index: mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py |
diff --git a/mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py b/mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py |
index f97fe91e31d71b1245ab248b06c0f4af589449fd..9f40dd6215343180ed676e61296b08b106b3192d 100644 |
--- a/mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py |
+++ b/mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py |
@@ -63,27 +63,8 @@ class LexerTest(unittest.TestCase): |
# Clone all lexer instances from this one, since making a lexer is slow. |
self._zygote_lexer = lex.lex(mojom.parse.lexer.Lexer("my_file.mojom")) |
- def testValidIdentifiers(self): |
- """Tests identifiers.""" |
- self.assertEquals(self._SingleTokenForInput("abcd"), |
- _MakeLexToken("NAME", "abcd")) |
- self.assertEquals(self._SingleTokenForInput("AbC_d012_"), |
- _MakeLexToken("NAME", "AbC_d012_")) |
- self.assertEquals(self._SingleTokenForInput("_0123"), |
- _MakeLexToken("NAME", "_0123")) |
- |
- def testInvalidIdentifiers(self): |
- with self.assertRaisesRegexp( |
- mojom.parse.lexer.LexError, |
- r"^my_file\.mojom:1: Error: Illegal character '\$'$"): |
- self._TokensForInput("$abc") |
- with self.assertRaisesRegexp( |
- mojom.parse.lexer.LexError, |
- r"^my_file\.mojom:1: Error: Illegal character '\$'$"): |
- self._TokensForInput("a$bc") |
- |
- def testValidSingleKeywords(self): |
- """Tests valid, single keywords.""" |
+ def testValidKeywords(self): |
+ """Tests valid keywords.""" |
self.assertEquals(self._SingleTokenForInput("handle"), |
_MakeLexTokenForKeyword("handle")) |
self.assertEquals(self._SingleTokenForInput("data_pipe_consumer"), |
@@ -103,8 +84,38 @@ class LexerTest(unittest.TestCase): |
self.assertEquals(self._SingleTokenForInput("enum"), |
_MakeLexTokenForKeyword("enum")) |
- def testValidSingleTokens(self): |
- """Tests valid, single (non-keyword) tokens.""" |
+ def testValidIdentifiers(self): |
+ """Tests identifiers.""" |
+ self.assertEquals(self._SingleTokenForInput("abcd"), |
+ _MakeLexToken("NAME", "abcd")) |
+ self.assertEquals(self._SingleTokenForInput("AbC_d012_"), |
+ _MakeLexToken("NAME", "AbC_d012_")) |
+ self.assertEquals(self._SingleTokenForInput("_0123"), |
+ _MakeLexToken("NAME", "_0123")) |
+ |
+ def testInvalidIdentifiers(self): |
+ with self.assertRaisesRegexp( |
+ mojom.parse.lexer.LexError, |
+ r"^my_file\.mojom:1: Error: Illegal character '\$'$"): |
+ self._TokensForInput("$abc") |
+ with self.assertRaisesRegexp( |
+ mojom.parse.lexer.LexError, |
+ r"^my_file\.mojom:1: Error: Illegal character '\$'$"): |
+ self._TokensForInput("a$bc") |
+ |
+ def testDecimalIntegerConstants(self): |
+ self.assertEquals(self._SingleTokenForInput("0"), |
+ _MakeLexToken("INT_CONST_DEC", "0")) |
+ self.assertEquals(self._SingleTokenForInput("1"), |
+ _MakeLexToken("INT_CONST_DEC", "1")) |
+ self.assertEquals(self._SingleTokenForInput("123"), |
+ _MakeLexToken("INT_CONST_DEC", "123")) |
+ self.assertEquals(self._SingleTokenForInput("10"), |
+ _MakeLexToken("INT_CONST_DEC", "10")) |
+ |
+ def testValidTokens(self): |
+ """Tests valid tokens (which aren't tested elsewhere).""" |
+ # Keywords tested in |testValidKeywords|. |
# NAME tested in |testValidIdentifiers|. |
self.assertEquals(self._SingleTokenForInput("@123"), |
_MakeLexToken("ORDINAL", "@123")) |