示例#1
0
    def testNameResolution(self):
        program = util.source('''
            class A(B):
                pass

            class B(A):
                pass
        ''')

        ast = parse(lex(program))
        globalScope = Scope()

        semantic.collectNames(ast, globalScope)
        semantic.resolveNames(ast, globalScope)
示例#2
0
    def testCollectNames(self):
        program = util.source('''
            class A(B):
                pass

            class B(A):
                pass
        ''')

        ast = parse(lex(program))
        globalScope = Scope()

        semantic.collectNames(ast, globalScope)

        self.assertTrue('A' in globalScope.symbols)
        self.assertTrue('B' in globalScope.symbols)