def testErrorBeforeAndInFormula(self): tree = self.parse("gibberish\nt1 {\n ~\n}\n") self.failUnless(absyn.CheckTree(tree)) #print tree.pretty() formula = tree.children[0] self.failUnless(formula.type == "formula") err = formula.children[0] self.failUnless(err.type == "error") self.assertNotEqual(re.search("^3:", err.leaf), None, "bad error message line number")
def assertIsBadFormula(self, s, message, line): t1 = self.parse(s) #print t1.pretty() self.failUnless(absyn.CheckTree(t1), "invalid tree created") formula = t1.children[0] self.failUnless(formula.type == "formula") err = formula.children[0] self.failUnless(err.type == "error", "error not found") #print err.leaf self.assertNotEqual(re.search(message, err.leaf), None, ("bad error message text '%s'", err.leaf)) self.assertNotEqual( re.search(("^%s:" % line), err.leaf), None, ("bad error message line number in '%s'", err.leaf))
def disabled_testGibberish(self): # parser doesn't like this, but can't think of a good fix right now t = self.parse(''' t1 { ''') self.failUnless(absyn.CheckTree(t))
def testErrorAfterFormula(self): tree = self.parse("t1{\n}\ngibberish") self.failUnless(absyn.CheckTree(tree))
def testErrorThenFormula(self): tree = self.parse("gibberish~\nt1 {\n}\n") self.failUnless(absyn.CheckTree(tree)) #print tree.pretty() formula = tree.children[0] self.failUnless(formula.type == "formula" and formula.leaf == "t1")
def testEmptyFormula(self): tree = self.parse("t1 {\n}\n") self.failUnless(absyn.CheckTree(tree)) formula = tree.children[0] self.failUnless(formula.type == "formula" and formula.leaf == "t1")
def testEmpty(self): tree = self.parse("\n") self.failUnless(absyn.CheckTree(tree))
def assertIsValidParse(self, t1): self.failUnless(absyn.CheckTree(t1)) errors = self.allNodesOfType(t1, "error") self.assertEqual(errors, [], [str(e) for e in errors])