Exemplo n.º 1
0
 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")
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
 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))
Exemplo n.º 4
0
 def testErrorAfterFormula(self):
     tree = self.parse("t1{\n}\ngibberish")
     self.assertTrue(absyn.CheckTree(tree))
Exemplo n.º 5
0
 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")
Exemplo n.º 6
0
 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")
Exemplo n.º 7
0
 def testEmpty(self):
     tree = self.parse("\n")
     self.assertTrue(absyn.CheckTree(tree))
Exemplo n.º 8
0
 def assertIsValidParse(self, t1):
     self.assertTrue(absyn.CheckTree(t1))
     errors = self.allNodesOfType(t1, "error")
     self.assertEqual(errors, [], [str(e) for e in errors])