mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testInvalidStructDefinitions(self):
    """Tests that definitions that aren't allowed in a struct are correctly
    detected."""

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

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

    source3 = """\
        struct MyStruct {
          interface MyInterface {
            MyMethod(int32 a);
          };
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Unexpected 'interface':\n"
        r" *interface MyInterface {$"):
      parser.Parse(source3, "my_file.mojom")
Tests that definitions that aren't allowed in a struct are correctly
    detected.
Tests that definitions that aren't allowed in a struct are correctly
detected.
Tests that definitions that aren ' t allowed in a struct are correctly detected .
def testInvalidStructDefinitions(self):
    source1 = """\
        struct MyStruct {
          MyMethod(int32 a);
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:2: Error: Unexpected '\(':\n"
        r" *MyMethod\(int32 a\);$"):
      parser.Parse(source1, "my_file.mojom")
    source2 = """\
        struct MyStruct {
          struct MyInnerStruct {
            int32 a;
          };
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:2: Error: Unexpected 'struct':\n"
        r" *struct MyInnerStruct {$"):
      parser.Parse(source2, "my_file.mojom")
    source3 = """\
        struct MyStruct {
          interface MyInterface {
            MyMethod(int32 a);
          };
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Unexpected 'interface':\n"
        r" *interface MyInterface {$"):
      parser.Parse(source3, "my_file.mojom")
def testInvalidStructDefinitions ( self ) : source1 = """\
        struct MyStruct {
          MyMethod(int32 a);
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Unexpected '\(':\n" r" *MyMethod\(int32 a\);$" ) : parser . Parse ( source1 , "my_file.mojom" ) source2 = """\
        struct MyStruct {
          struct MyInnerStruct {
            int32 a;
          };
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Unexpected 'struct':\n" r" *struct MyInnerStruct {$" ) : parser . Parse ( source2 , "my_file.mojom" ) source3 = """\
        struct MyStruct {
          interface MyInterface {
            MyMethod(int32 a);
          };
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Unexpected 'interface':\n" r" *interface MyInterface {$" ) : parser . Parse ( source3 , "my_file.mojom" )
Tests that definitions that aren't allowed in a struct are correctly
detected.
Tests that definitions that aren ' t allowed in a struct are correctly detected .
"""Tests that definitions that aren't allowed in a struct are correctly
    detected."""
self