mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testMissingModuleName(self):
    """Tests an (invalid) .mojom with a missing module name."""

    source1 = """\
        // Missing module name.
        module ;
        struct MyStruct {
          int32 a;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Unexpected ';':\n *module ;$"):
      parser.Parse(source1, "my_file.mojom")

    # Another similar case, but make sure that line-number tracking/reporting
    # is correct.
    source2 = """\
        module
        // This line intentionally left unblank.

        struct MyStruct {
          int32 a;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:4: Error: Unexpected 'struct':\n"
        r" *struct MyStruct {$"):
      parser.Parse(source2, "my_file.mojom")
Tests an (invalid) .mojom with a missing module name.
Tests an (invalid) .mojom with a missing module name.
Tests an ( invalid ) . mojom with a missing module name .
def testMissingModuleName(self):
    source1 = """\
        // Missing module name.
        module ;
        struct MyStruct {
          int32 a;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Unexpected ';':\n *module ;$"):
      parser.Parse(source1, "my_file.mojom")
    source2 = """\
        module
        // This line intentionally left unblank.
        struct MyStruct {
          int32 a;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:4: Error: Unexpected 'struct':\n"
        r" *struct MyStruct {$"):
      parser.Parse(source2, "my_file.mojom")
def testMissingModuleName ( self ) : source1 = """\
        // Missing module name.
        module ;
        struct MyStruct {
          int32 a;
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Unexpected ';':\n *module ;$" ) : parser . Parse ( source1 , "my_file.mojom" ) source2 = """\
        module
        // This line intentionally left unblank.

        struct MyStruct {
          int32 a;
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:4: Error: Unexpected 'struct':\n" r" *struct MyStruct {$" ) : parser . Parse ( source2 , "my_file.mojom" )
Tests an (invalid) .mojom with a missing module name.
Tests an ( invalid ) . mojom with a missing module name .
"""Tests an (invalid) .mojom with a missing module name.""" # Another similar case, but make sure that line-number tracking/reporting # is correct.
self