def testSemantic1(self): util.semanticProgram( util.source(''' class NineTest: pass ''') )
def testVirtualOverrideKeywords3(self): program = util.source(''' class A_Class: virtual def Method(): pass class B_Class(A_Class): override def Method(): pass ''') util.semanticProgram(program)
def testVirtualOverrideKeywords1(self): program = util.source(''' class A_Class: override def Bork(): pass ''') self.assertRaises( error.OverrideError, lambda: util.semanticProgram(program) )
def testSemantic2(self): program = util.source(''' class NineTest: var x def Method(): pass ''') self.failUnlessRaises( error.SyntaxError, lambda: util.semanticProgram(program) )
def testCircularInheritance(self): program = util.source(''' class A(B): pass class B(A): pass ''') self.assertRaises( error.CircularInheritanceError, lambda: util.semanticProgram(program) )
def testSemantic3(self): program = util.source(''' class DuplicateName: pass class DuplicateName: var x def Method(): pass ''') self.failUnlessRaises( error.NameError, lambda: util.semanticProgram(program) )
def testVirtualOverrideKeywords2(self): program = util.source(''' class A_Class: override def Method(): pass class B_Class(A_Class): override def Method(x as int): pass ''' ) self.assertRaises( error.OverrideError, lambda: util.semanticProgram(program) )
def testGetMethod(self): "testGetMethod: Test ClassDecl.getMethod()" from ast import vartypes program = util.source(''' class A_Class: virtual def Method(): pass class B_Class(A_Class): override def Method(): pass ''') result = util.semanticProgram(program).pop() assert isinstance(result, ClassDecl) assert result.getMethod("Method", (), vartypes.VoidType) is not None
def testSealedMethod(self): program = util.source(''' class A: virtual def Method(): print 'A' class B(A): sealed override def Method(): print 'B' class C(B): override def Method(): print 'C' ''') self.assertRaises( error.OverrideError, lambda: util.semanticProgram(program) )