Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py

Issue 290693003: Mojo: Mojom: Remove integer suffixes (e.g., u, l, ul, etc.). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/lexer.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"))
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/lexer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698