mojo/public/tools/mojom/mojom/parse/parser_unittest.py
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':\n *asdf1$"):
      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':\n *asdf2$"):
      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':\n *asdf3$"):
      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':\n *asdf4$"):
      parser.Parse(source4, "my_file.mojom")
Tests that line numbers are correctly tracked when comments are
    present.
Tests that line numbers are correctly tracked when comments are
present.
Tests that line numbers are correctly tracked when comments are present .
def testCommentLineNumbers(self):
    source1 = """\
        // Isolated C++-style comments.
        // Foo.
        asdf1
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:4: Error: Unexpected 'asdf1':\n *asdf1$"):
      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':\n *asdf2$"):
      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':\n *asdf3$"):
      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':\n *asdf4$"):
      parser.Parse(source4, "my_file.mojom")
def testCommentLineNumbers ( self ) : source1 = """\
        // Isolated C++-style comments.

        // Foo.
        asdf1
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:4: Error: Unexpected 'asdf1':\n *asdf1$" ) : 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':\n *asdf2$" ) : 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':\n *asdf3$" ) : 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':\n *asdf4$" ) : parser . Parse ( source4 , "my_file.mojom" )
Tests that line numbers are correctly tracked when comments are
present.
Tests that line numbers are correctly tracked when comments are present .
"""Tests that line numbers are correctly tracked when comments are
    present."""
self