Example #1
0
        self.m1i = make_type_info('M1', (INTERFACES, [self.gfi]),
                                  (BASE_DEFS, [Instance(self.gfi, [self.a])]))

        self.gfa = Instance(self.gfi, [self.a]) # GF<A>
        self.gfb = Instance(self.gfi, [self.b]) # GF<B>

        self.m1 = Instance(self.m1i, []) # M1


TypeInfo make_type_info(any name, any *args):
    """Make a TypeInfo suitable for use in unit tests."""
    map = dict(args)
    
    type_def = TypeDef(name, Block([]), None, [])
    type_def.full_name = name
    
    if VARS in map:
        TypeVarDef[] v = []
        id = 1
        for n in map[VARS]:
            v.append(TypeVarDef(n, id))
            id += 1
        type_def.type_vars = TypeVars(v)
    
    info = TypeInfo({}, {}, type_def)
    info.base = map.get(BASE, None)
    info.bases = map.get(BASE_DEFS, [])
    info.interfaces = map.get(INTERFACES, []) # TODO fix
    
    return info