mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testValidAssociatedKinds(self):
    """Tests parsing associated interfaces and requests."""
    source1 = """\
        struct MyStruct {
          associated MyInterface a;
          associated MyInterface& b;
          associated MyInterface? c;
          associated MyInterface&? d;
        };
        """
    expected1 = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody([
                ast.StructField('a', None, None, 'asso<MyInterface>', None),
                ast.StructField('b', None, None, 'asso<MyInterface&>', None),
                ast.StructField('c', None, None, 'asso<MyInterface>?', None),
                ast.StructField('d', None, None, 'asso<MyInterface&>?', None)
            ]))
    ])
    self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1)

    source2 = """\
        interface MyInterface {
          MyMethod(associated A a) =>(associated B& b);
        };"""
    expected2 = ast.Mojom(None, ast.ImportList(), [
        ast.Interface(
            'MyInterface', None,
            ast.InterfaceBody(
                ast.Method(
                    'MyMethod', None, None,
                    ast.ParameterList(
                        ast.Parameter('a', None, None, 'asso<A>')),
                    ast.ParameterList(
                        ast.Parameter('b', None, None, 'asso<B&>')))))
    ])
    self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2)
Tests parsing associated interfaces and requests.
Tests parsing associated interfaces and requests.
Tests parsing associated interfaces and requests .
def testValidAssociatedKinds(self):
    source1 = """\
        struct MyStruct {
          associated MyInterface a;
          associated MyInterface& b;
          associated MyInterface? c;
          associated MyInterface&? d;
        };
        """
    expected1 = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody([
                ast.StructField('a', None, None, 'asso<MyInterface>', None),
                ast.StructField('b', None, None, 'asso<MyInterface&>', None),
                ast.StructField('c', None, None, 'asso<MyInterface>?', None),
                ast.StructField('d', None, None, 'asso<MyInterface&>?', None)
            ]))
    ])
    self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1)
    source2 = """\
        interface MyInterface {
          MyMethod(associated A a) =>(associated B& b);
        };"""
    expected2 = ast.Mojom(None, ast.ImportList(), [
        ast.Interface(
            'MyInterface', None,
            ast.InterfaceBody(
                ast.Method(
                    'MyMethod', None, None,
                    ast.ParameterList(
                        ast.Parameter('a', None, None, 'asso<A>')),
                    ast.ParameterList(
                        ast.Parameter('b', None, None, 'asso<B&>')))))
    ])
    self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2)
def testValidAssociatedKinds ( self ) : source1 = """\
        struct MyStruct {
          associated MyInterface a;
          associated MyInterface& b;
          associated MyInterface? c;
          associated MyInterface&? d;
        };
        """ expected1 = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Struct ( 'MyStruct' , None , ast . StructBody ( [ ast . StructField ( 'a' , None , None , 'asso<MyInterface>' , None ) , ast . StructField ( 'b' , None , None , 'asso<MyInterface&>' , None ) , ast . StructField ( 'c' , None , None , 'asso<MyInterface>?' , None ) , ast . StructField ( 'd' , None , None , 'asso<MyInterface&>?' , None ) ] ) ) ] ) self . assertEquals ( parser . Parse ( source1 , "my_file.mojom" ) , expected1 ) source2 = """\
        interface MyInterface {
          MyMethod(associated A a) =>(associated B& b);
        };""" expected2 = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Interface ( 'MyInterface' , None , ast . InterfaceBody ( ast . Method ( 'MyMethod' , None , None , ast . ParameterList ( ast . Parameter ( 'a' , None , None , 'asso<A>' ) ) , ast . ParameterList ( ast . Parameter ( 'b' , None , None , 'asso<B&>' ) ) ) ) ) ] ) self . assertEquals ( parser . Parse ( source2 , "my_file.mojom" ) , expected2 )
Tests parsing associated interfaces and requests.
Tests parsing associated interfaces and requests .
"""Tests parsing associated interfaces and requests."""
self