Пример #1
0
    def test_first_example(self):
        expr = '1 + (2 * 3) + (4 * (5 + 6))'
        rpn = shunting_yard_alg(expr, self.prec)

        should_be = 51
        self.assertEqual(solve_rpn(rpn), should_be)
Пример #2
0
    def test_fifth_example(self):
        expr = '((2 + 4 * 9) * (6 + 9 * 8 + 6) + 6) + 2 + 4 * 2'
        rpn = shunting_yard_alg(expr, self.prec)

        should_be = 13632
        self.assertEqual(solve_rpn(rpn), should_be)
Пример #3
0
    def test_third_example(self):
        expr = '5 + (8 * 3 + 9 + 3 * 4 * 3)'
        rpn = shunting_yard_alg(expr, self.prec)

        should_be = 437
        self.assertEqual(solve_rpn(rpn), should_be)
Пример #4
0
    def test_fourth_example(self):
        expr = '5 * 9 * (7 * 3 * 3 + 9 * 3 + (8 + 6 * 4))'
        rpn = shunting_yard_alg(expr, self.prec)

        should_be = 12240
        self.assertEqual(solve_rpn(rpn), should_be)
Пример #5
0
    def test_second_example(self):
        expr = '2 * 3 + (4 * 5)'
        rpn = shunting_yard_alg(expr, self.prec)

        should_be = 26
        self.assertEqual(solve_rpn(rpn), should_be)