def Parse(self): """ Parses arguments and parse expression.""" args = self._parser.parse_args() if args.EXPRESSION: py_calc = pycalc.PyCalc(args.EXPRESSION) print py_calc.Parse()
def testParseNominal4(self): py_calc = pycalc.PyCalc('sin(4+2)') result = py_calc.Parse() self.assertEqual(result, -0.27941549819892586)
def testParseNominal3(self): py_calc = pycalc.PyCalc('(4+2)*(2+4)') result = py_calc.Parse() self.assertEqual(result, 36)
def testParseNominal2(self): py_calc = pycalc.PyCalc('4+2') result = py_calc.Parse() self.assertEqual(result, 6)
def testParseNominal(self): py_calc = pycalc.PyCalc('(4+2)*4') result = py_calc.Parse() self.assertEqual(result, 24)
def testToPostfixSin(self): py_calc = pycalc.PyCalc('') result = py_calc._ToPostfix('sin(2+3)') self.assertEqual(result, ['2', '3', '+', 'sin'])
def testToPostfixFail(self): py_calc = pycalc.PyCalc('') result = py_calc._ToPostfix('test') self.assertEqual(result, [])
def testToPostfixNominal(self): py_calc = pycalc.PyCalc('') result = py_calc._ToPostfix('(4+2)*4') self.assertEqual(result, ['4', '2', '+', '4', '*'])
def testToPostfixSimply(self): py_calc = pycalc.PyCalc('') result = py_calc._ToPostfix('3+4') self.assertEqual(result, ['3', '4', '+'])