예제 #1
0
 def test_invalid_formulas(self, inputs):
     with self.assertRaises(FormulaError):
         Parser().ast(inputs)
예제 #2
0
 def test_invalid_compile(self, case):
     formula, inputs = case
     with self.assertRaises(sh.DispatcherError):
         Parser().ast(formula)[1].compile()(*inputs)
예제 #3
0
 def test_valid_formula(self, case):
     inputs, result = case
     tokens, ast = Parser().ast(inputs)
     output = ''.join(t.name for t in tokens)
     self.assertEqual(result, output, '%s != %s' % (result, output))
예제 #4
0
 def test_compile(self, case):
     references, formula, inputs, result = case
     func = Parser().ast(formula)[1].compile(references)
     output = str(func(*inputs))
     self.assertEqual(result, output, '{} != {}'.format(result, output))