mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testEnums(self):
    """Tests that enum statements are correctly parsed."""

    source = """\
        module my_module;
        enum MyEnum1 { VALUE1, VALUE2 };  // No trailing comma.
        enum MyEnum2 {
          VALUE1 = -1,
          VALUE2 = 0,
          VALUE3 = + 987,  // Check that space is allowed.
          VALUE4 = 0xAF12,
          VALUE5 = -0x09bcd,
          VALUE6 = VALUE5,
          VALUE7,  // Leave trailing comma.
        };
        """
    expected = ast.Mojom(
        ast.Module(('IDENTIFIER', 'my_module'), None), ast.ImportList(), [
            ast.Enum(
                'MyEnum1', None,
                ast.EnumValueList([
                    ast.EnumValue('VALUE1', None, None),
                    ast.EnumValue('VALUE2', None, None)
                ])),
            ast.Enum(
                'MyEnum2', None,
                ast.EnumValueList([
                    ast.EnumValue('VALUE1', None, '-1'),
                    ast.EnumValue('VALUE2', None, '0'),
                    ast.EnumValue('VALUE3', None, '+987'),
                    ast.EnumValue('VALUE4', None, '0xAF12'),
                    ast.EnumValue('VALUE5', None, '-0x09bcd'),
                    ast.EnumValue('VALUE6', None, ('IDENTIFIER', 'VALUE5')),
                    ast.EnumValue('VALUE7', None, None)
                ]))
        ])
    self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
Tests that enum statements are correctly parsed.
Tests that enum statements are correctly parsed.
Tests that enum statements are correctly parsed .
def testEnums(self):
    source = """\
        module my_module;
        enum MyEnum1 { VALUE1, VALUE2 };  // No trailing comma.
        enum MyEnum2 {
          VALUE1 = -1,
          VALUE2 = 0,
          VALUE3 = + 987,  // Check that space is allowed.
          VALUE4 = 0xAF12,
          VALUE5 = -0x09bcd,
          VALUE6 = VALUE5,
          VALUE7,  // Leave trailing comma.
        };
        """
    expected = ast.Mojom(
        ast.Module(('IDENTIFIER', 'my_module'), None), ast.ImportList(), [
            ast.Enum(
                'MyEnum1', None,
                ast.EnumValueList([
                    ast.EnumValue('VALUE1', None, None),
                    ast.EnumValue('VALUE2', None, None)
                ])),
            ast.Enum(
                'MyEnum2', None,
                ast.EnumValueList([
                    ast.EnumValue('VALUE1', None, '-1'),
                    ast.EnumValue('VALUE2', None, '0'),
                    ast.EnumValue('VALUE3', None, '+987'),
                    ast.EnumValue('VALUE4', None, '0xAF12'),
                    ast.EnumValue('VALUE5', None, '-0x09bcd'),
                    ast.EnumValue('VALUE6', None, ('IDENTIFIER', 'VALUE5')),
                    ast.EnumValue('VALUE7', None, None)
                ]))
        ])
    self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
def testEnums ( self ) : source = """\
        module my_module;
        enum MyEnum1 { VALUE1, VALUE2 };  // No trailing comma.
        enum MyEnum2 {
          VALUE1 = -1,
          VALUE2 = 0,
          VALUE3 = + 987,  // Check that space is allowed.
          VALUE4 = 0xAF12,
          VALUE5 = -0x09bcd,
          VALUE6 = VALUE5,
          VALUE7,  // Leave trailing comma.
        };
        """ expected = ast . Mojom ( ast . Module ( ( 'IDENTIFIER' , 'my_module' ) , None ) , ast . ImportList ( ) , [ ast . Enum ( 'MyEnum1' , None , ast . EnumValueList ( [ ast . EnumValue ( 'VALUE1' , None , None ) , ast . EnumValue ( 'VALUE2' , None , None ) ] ) ) , ast . Enum ( 'MyEnum2' , None , ast . EnumValueList ( [ ast . EnumValue ( 'VALUE1' , None , '-1' ) , ast . EnumValue ( 'VALUE2' , None , '0' ) , ast . EnumValue ( 'VALUE3' , None , '+987' ) , ast . EnumValue ( 'VALUE4' , None , '0xAF12' ) , ast . EnumValue ( 'VALUE5' , None , '-0x09bcd' ) , ast . EnumValue ( 'VALUE6' , None , ( 'IDENTIFIER' , 'VALUE5' ) ) , ast . EnumValue ( 'VALUE7' , None , None ) ] ) ) ] ) self . assertEquals ( parser . Parse ( source , "my_file.mojom" ) , expected )
Tests that enum statements are correctly parsed.
Tests that enum statements are correctly parsed .
"""Tests that enum statements are correctly parsed."""
self