def testBadSemeantic(self): program = 'if 1<2:\n pass\nelse:\n pass\nelif 1<2:\n pass\n' tokens = lex(program) iS = IfStatement.parse(tokens) sIS = iS.semantic(Scope(None)) self.assertRaises(Exception, iS.semantic(Scope(None)))
def ifParse(): IfStatement.parse(tokens)
def testSemantic(self): program = 'if 1<2:\n pass\nelif 1<2:\n pass\nelse:\n pass\n' tokens = lex(program) iS = IfStatement.parse(tokens) sIS = iS.semantic(Scope(None)) self.failUnless(isinstance(sIS,IfStatement), tokens)
def testParse(self): program = 'if 1<2:\n pass\nelse:\n pass\n' tokens = lex(program) i = IfStatement.parse(tokens) self.failUnless(isinstance(i, IfStatement))