mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testValidAssociativeArrays(self):
    """Tests that we can parse valid associative array structures."""

    source1 = "struct MyStruct { map<string, uint8> data; };"
    expected1 = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody(
                [ast.StructField('data', None, None, 'uint8{string}', None)]))
    ])
    self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1)

    source2 = "interface MyInterface { MyMethod(map<string, uint8> a); };"
    expected2 = ast.Mojom(None, ast.ImportList(), [
        ast.Interface(
            'MyInterface', None,
            ast.InterfaceBody(
                ast.Method(
                    'MyMethod', None, None,
                    ast.ParameterList(
                        ast.Parameter('a', None, None, 'uint8{string}')),
                    None)))
    ])
    self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2)

    source3 = "struct MyStruct { map<string, array<uint8>> data; };"
    expected3 = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody(
                [ast.StructField('data', None, None, 'uint8[]{string}', None)]))
    ])
    self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3)
Tests that we can parse valid associative array structures.
Tests that we can parse valid associative array structures.
Tests that we can parse valid associative array structures .
def testValidAssociativeArrays(self):
    source1 = "struct MyStruct { map<string, uint8> data; };"
    expected1 = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody(
                [ast.StructField('data', None, None, 'uint8{string}', None)]))
    ])
    self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1)
    source2 = "interface MyInterface { MyMethod(map<string, uint8> a); };"
    expected2 = ast.Mojom(None, ast.ImportList(), [
        ast.Interface(
            'MyInterface', None,
            ast.InterfaceBody(
                ast.Method(
                    'MyMethod', None, None,
                    ast.ParameterList(
                        ast.Parameter('a', None, None, 'uint8{string}')),
                    None)))
    ])
    self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2)
    source3 = "struct MyStruct { map<string, array<uint8>> data; };"
    expected3 = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody(
                [ast.StructField('data', None, None, 'uint8[]{string}', None)]))
    ])
    self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3)
def testValidAssociativeArrays ( self ) : source1 = "struct MyStruct { map<string, uint8> data; };" expected1 = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Struct ( 'MyStruct' , None , ast . StructBody ( [ ast . StructField ( 'data' , None , None , 'uint8{string}' , None ) ] ) ) ] ) self . assertEquals ( parser . Parse ( source1 , "my_file.mojom" ) , expected1 ) source2 = "interface MyInterface { MyMethod(map<string, uint8> a); };" expected2 = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Interface ( 'MyInterface' , None , ast . InterfaceBody ( ast . Method ( 'MyMethod' , None , None , ast . ParameterList ( ast . Parameter ( 'a' , None , None , 'uint8{string}' ) ) , None ) ) ) ] ) self . assertEquals ( parser . Parse ( source2 , "my_file.mojom" ) , expected2 ) source3 = "struct MyStruct { map<string, array<uint8>> data; };" expected3 = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Struct ( 'MyStruct' , None , ast . StructBody ( [ ast . StructField ( 'data' , None , None , 'uint8[]{string}' , None ) ] ) ) ] ) self . assertEquals ( parser . Parse ( source3 , "my_file.mojom" ) , expected3 )
Tests that we can parse valid associative array structures.
Tests that we can parse valid associative array structures .
"""Tests that we can parse valid associative array structures."""
self