Beispiel #1
0
 def test_modulus(self):
     expect = 7
     actual = calc.calc_iteration(calc.to_postfix('29%11'), None)
     self.assertEqual(expect, actual)
Beispiel #2
0
 def test_modulo_by_zero(self):
     with self.assertRaises(calc.CalcError):
         calc.calc_iteration(calc.to_postfix('3 % 0'), None)
Beispiel #3
0
 def test_division(self):
     expect = 6
     actual = calc.calc_iteration(calc.to_postfix('24/4'), None)
     self.assertEqual(expect, actual)
Beispiel #4
0
 def test_division_by_zero(self):
     with self.assertRaises(calc.CalcError):
         calc.calc_iteration(calc.to_postfix('3 / 0'), None)
Beispiel #5
0
 def test_subtraction(self):
     expect = 3
     actual = calc.calc_iteration(calc.to_postfix('25-22'), None)
     self.assertEqual(expect, actual)
Beispiel #6
0
 def test_multiplication(self):
     expect = 5
     actual = calc.calc_iteration(calc.to_postfix('2.5*2'), None)
     self.assertEqual(expect, actual)
Beispiel #7
0
 def test_comparison(self):
     expect = True
     actual = calc.calc_iteration(calc.to_postfix('2+3*5>=10+12/2'), None)
     self.assertEqual(expect, actual)
Beispiel #8
0
 def test_addition(self):
     expect = 8.05
     actual = calc.calc_iteration(calc.to_postfix('3.5+.5+2.75+1.3'), None)
     self.assertEqual(expect, actual)
Beispiel #9
0
 def test_calc_iteration(self):
     expect = (1, 8)
     actual = (calc.calc_iteration(['sin', 'pi', '2', '/', ')'], None),
               calc.calc_iteration(['pow', '2', ',', '3', ')'], None))
     self.assertEqual(expect, actual)
Beispiel #10
0
 def test_abs(self):
     expect = 6
     actual = calc.calc_iteration(calc.to_postfix('abs(-6)'), None)
     self.assertEqual(expect, actual)
Beispiel #11
0
 def test_round(self):
     expect = 8
     actual = calc.calc_iteration(calc.to_postfix('round(7.51)'), None)
     self.assertEqual(expect, actual)
Beispiel #12
0
 def test_power(self):
     expect = 8
     actual = calc.calc_iteration(calc.to_postfix('2^3'), None)
     self.assertEqual(expect, actual)
Beispiel #13
0
 def test_floor_division(self):
     expect = 4
     actual = calc.calc_iteration(calc.to_postfix('9//2'), None)
     self.assertEqual(expect, actual)