예제 #1
0
 def test_eval_reverse_polish_notation_list_simple_case_multiplication(self):
     val = [1, 2, "*"]
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertEqual(2, res)
예제 #2
0
 def test_eval_reverse_polish_notation_list_none(self):
     res = ValueEvaluator.eval_reverse_polish_notation_list(None)
     self.assertIsNone(res)
예제 #3
0
 def test_eval_reverse_polish_notation_list_simple_case_sub(self):
     val = [1, 2, "-"]
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertEqual(-1, res)
예제 #4
0
 def test_eval_reverse_polish_notation_string_simple_multiply(self):
     val = "2 3 *"
     res = ValueEvaluator.eval_reverse_polish_notation(val)
     self.assertEqual(6, res)
예제 #5
0
 def test_eval_reverse_polish_notation_string_simple_sum(self):
     val = "2 3 /"
     res = ValueEvaluator.eval_reverse_polish_notation(val)
     self.assertEqual(float(2) / 3, res)
예제 #6
0
 def test_eval_reverse_polish_notation_string_simple_sub(self):
     val = "2 3 -"
     res = ValueEvaluator.eval_reverse_polish_notation(val)
     self.assertEqual(-1, res)
예제 #7
0
 def test_eval_reverse_polish_notation_string_simple_sub(self):
     val = "2 3 -"
     res = ValueEvaluator.eval_reverse_polish_notation(val)
     self.assertEqual(-1, res)
예제 #8
0
 def test_eval_reverse_polish_notation_list_simple_case_division(self):
     val = [1, 2, "/"]
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertAlmostEqual(0.5, res)
예제 #9
0
 def test_eval_reverse_polish_notation_list_complex_formula(self):
     val = [1, 2, "+", 4, "*", 6, "/", 4, '-']
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertAlmostEqual(-2, res)
예제 #10
0
 def test_eval_reverse_polish_notation_list_simple_case_sub(self):
     val = [1, 2, "-"]
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertEqual(-1, res)
예제 #11
0
 def test_eval_reverse_polish_notation_list_simple_case_multiplication(
         self):
     val = [1, 2, "*"]
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertEqual(2, res)
예제 #12
0
 def test_eval_reverse_polish_notation_list_none(self):
     res = ValueEvaluator.eval_reverse_polish_notation_list(None)
     self.assertIsNone(res)
예제 #13
0
 def test_eval_reverse_polish_notation_string_simple_sum(self):
     val = "2 3 /"
     res = ValueEvaluator.eval_reverse_polish_notation(val)
     self.assertEqual(float(2) / 3, res)
예제 #14
0
 def test_eval_reverse_polish_notation_string_simple_multiply(self):
     val = "2 3 *"
     res = ValueEvaluator.eval_reverse_polish_notation(val)
     self.assertEqual(6, res)
예제 #15
0
 def test_eval_reverse_polish_notation_list_simple_case_division(self):
     val = [1, 2, "/"]
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertAlmostEqual(0.5, res)
예제 #16
0
 def test_eval_reverse_polish_notation_empty_string(self):
     res = ValueEvaluator.eval_reverse_polish_notation("")
     self.assertIsNone(res)
예제 #17
0
 def test_eval_reverse_polish_notation_list_complex_formula(self):
     val = [1, 2, "+", 4, "*", 6, "/", 4, '-']
     res = ValueEvaluator.eval_reverse_polish_notation_list(val)
     self.assertAlmostEqual(-2, res)
예제 #18
0
 def test_eval_reverse_polish_notation_empty_string(self):
     res = ValueEvaluator.eval_reverse_polish_notation("")
     self.assertIsNone(res)