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

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

Issue 293053011: Mojo: Mojom: Fix line number tracking when there are comments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/parser_unittest.py
diff --git a/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py b/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
index 5ef995b1d7499c63b72e162ed8385562ad87f009..c6b1a35496c9abb7f3a02d2e2eef017a869b3539 100644
--- a/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
+++ b/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
@@ -61,6 +61,67 @@ module my_module {
r"^my_file\.mojom: Error: Unexpected end of file$"):
parser.Parse(source, "my_file.mojom")
+ def testCommentLineNumbers(self):
+ """Tests that line numbers are correctly tracked when comments are
+ present."""
+ source1 = """\
+// Isolated C++-style comments.
+
+// Foo.
+asdf1
+"""
+ with self.assertRaisesRegexp(
+ parser.ParseError,
+ r"^my_file\.mojom:4: Error: Unexpected 'asdf1':\nasdf1$"):
+ parser.Parse(source1, "my_file.mojom")
+
+ source2 = """\
+// Consecutive C++-style comments.
+// Foo.
+ // Bar.
+
+struct Yada { // Baz.
+// Quux.
+ int32 x;
+};
+
+asdf2
+"""
+ with self.assertRaisesRegexp(
+ parser.ParseError,
+ r"^my_file\.mojom:10: Error: Unexpected 'asdf2':\nasdf2$"):
+ parser.Parse(source2, "my_file.mojom")
+
+ source3 = """\
+/* Single-line C-style comments. */
+/* Foobar. */
+
+/* Baz. */
+asdf3
+"""
+ with self.assertRaisesRegexp(
+ parser.ParseError,
+ r"^my_file\.mojom:5: Error: Unexpected 'asdf3':\nasdf3$"):
+ parser.Parse(source3, "my_file.mojom")
+
+ source4 = """\
+/* Multi-line C-style comments.
+*/
+/*
+Foo.
+Bar.
+*/
+
+/* Baz
+ Quux. */
+asdf4
+"""
+ with self.assertRaisesRegexp(
+ parser.ParseError,
+ r"^my_file\.mojom:10: Error: Unexpected 'asdf4':\nasdf4$"):
+ parser.Parse(source4, "my_file.mojom")
+
+
def testSimpleStruct(self):
"""Tests a simple .mojom source that just defines a struct."""
source = """\
« 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