コード例 #1
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)
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
 def test_eval_reverse_polish_notation_list_none(self):
     res = ValueEvaluator.eval_reverse_polish_notation_list(None)
     self.assertIsNone(res)
コード例 #5
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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
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)
コード例 #9
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)
コード例 #10
0
 def test_eval_reverse_polish_notation_list_none(self):
     res = ValueEvaluator.eval_reverse_polish_notation_list(None)
     self.assertIsNone(res)