def test_rpn_complex(self): istr4 = '0.2 10.24 pi * 180 / * 10.24 pi * 180 / sin /' rpnins4 = Rpn(istr4) self.assertAlmostEqual(rpnins4.solve(), 0.2 * (10.24 * math.pi) / 180 / math.sin(10.24 * math.pi / 180), places=NPRC)
def test(): istr1 = '1 2 + 3 * sin' rpnins1 = Rpn(istr1) print(rpnins1) print(rpnins1.solve()) istr2 = '1 2 + 3 * cos' rpnins2 = Rpn(istr2) print(rpnins2) print(rpnins2.solve()) istr3 = '10,3,1,2,/,*,-,tan' rpnins3 = Rpn(istr3, ',') print(rpnins3) print(rpnins3.solve()) istr4 = '0.2 10.24 pi * 180 / * 10.24 pi * 180 / sin /' rpnins4 = Rpn(istr4) print(rpnins4.solve()) istr5 = '0.2 10.24 pi * 180 / * 10.24 pi * 180 / sin /' print(Rpn.solve_rpn(istr5))
def test(): istr1 = '1 2 + 3 * sin' rpnins1 = Rpn(istr1) print rpnins1 print rpnins1.solve() istr2 = '1 2 + 3 * cos' rpnins2 = Rpn(istr2) print rpnins2 print rpnins2.solve() istr3 = '10,3,1,2,/,*,-,tan' rpnins3 = Rpn(istr3, ',') print rpnins3 print rpnins3.solve() istr4 = '0.2 10.24 pi * 180 / * 10.24 pi * 180 / sin /' rpnins4 = Rpn(istr4) print rpnins4.solve() istr5 = '0.2 10.24 pi * 180 / * 10.24 pi * 180 / sin /' print Rpn.solve_rpn(istr5)
def test_rpn_sto_2(self): """test sto operation: variables""" a = Rpn('1 2 + sto three') self.assertEqual(a.variables, {'pi': math.pi}) a.solve() self.assertEqual(a.variables, {'pi': math.pi, 'three': 3.0})
def test_rpn_sep(self): istr3 = '10,3,1,2,/,*,-,tan' rpnins3 = Rpn(istr3, ',') self.assertAlmostEqual(rpnins3.solve(), math.tan(10 - 3 * (1.0 / 2.0)), places=NPRC)
def test_rpn_func2(self): istr3 = '10 3 1 2 / * - tan' rpnins3 = Rpn(istr3) self.assertAlmostEqual(rpnins3.solve(), math.tan(10 - 3 * (1.0 / 2.0)), places=NPRC)
def test_rpn_func1(self): istr1 = '1 2 + 3 * sin' rpnins1 = Rpn(istr1) self.assertAlmostEqual(rpnins1.solve(), math.sin(3 * 3), places=NPRC)