def testErrorBeforeAndInFormula(self): tree = self.parse("gibberish\nt1 {\n ~\n}\n") self.assertTrue(absyn.CheckTree(tree)) #print tree.pretty() formula = tree.children[0] self.assertTrue(formula.type == "formula") err = formula.children[0] self.assertTrue(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) self.assertTrue(absyn.CheckTree(t1), "invalid tree created") formula = t1.children[0] self.assertTrue(formula.type == "formula") err = formula.children[0] self.assertTrue(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.assertTrue(absyn.CheckTree(t))
def testErrorAfterFormula(self): tree = self.parse("t1{\n}\ngibberish") self.assertTrue(absyn.CheckTree(tree))
def testErrorThenFormula(self): tree = self.parse("gibberish~\nt1 {\n}\n") self.assertTrue(absyn.CheckTree(tree)) #print tree.pretty() formula = tree.children[0] self.assertTrue(formula.type == "formula" and formula.leaf == "t1")
def testEmptyFormula(self): tree = self.parse("t1 {\n}\n") self.assertTrue(absyn.CheckTree(tree)) formula = tree.children[0] self.assertTrue(formula.type == "formula" and formula.leaf == "t1")
def testEmpty(self): tree = self.parse("\n") self.assertTrue(absyn.CheckTree(tree))
def assertIsValidParse(self, t1): self.assertTrue(absyn.CheckTree(t1)) errors = self.allNodesOfType(t1, "error") self.assertEqual(errors, [], [str(e) for e in errors])