Example #1
0
def test_infix_2():
    postfix = i2p("5  +7")
    assert postfix.replace(" ", "") == "5 7 +".replace(" ", "")
Example #2
0
 def test_infix_1(self):
     postfix = i2p("4")
     self.assertEqual(postfix.replace(" ", ""), "4")
Example #3
0
 def test_infix_3(self):
     postfix = i2p("7*5")
     self.assertEqual(postfix.replace(" ", ""), "7 5 *".replace(" ", ""))
Example #4
0
 def test_infix_11(self):
     postfix = i2p("((8+3)*2)-7")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 3 + 2 * 7 -".replace(" ", ""))
Example #5
0
 def test_infix_13(self):
     postfix = i2p("((8*5+3)-7)-(5*3)")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 5 * 3 + 7 - 5 3 * -".replace(" ", ""))
Example #6
0
 def test_infix_7(self):
     postfix = i2p("8*(5+3)")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 5 3 + *".replace(" ", ""))
Example #7
0
 def test_infix_9(self):
     postfix = i2p("(8+3)*(5-6)")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 3 + 5 6 - *".replace(" ", ""))
Example #8
0
def test_infix_8():
    postfix = i2p("8+3*5-7")
    assert postfix.replace(" ", "") == "8 3 5 * + 7 -".replace(" ", "")
Example #9
0
def test_infix_9():
    postfix = i2p("(8+3)*(5-6)")
    assert postfix.replace(" ", "") == "8 3 + 5 6 - *".replace(" ", "")
Example #10
0
def test_infix_6():
    postfix = i2p("8*5+3")
    assert postfix.replace(" ", "") == "8 5 * 3 +".replace(" ", "")
Example #11
0
def test_infix_7():
    postfix = i2p("8*(5+3)")
    assert postfix.replace(" ", "") == "8 5 3 + *".replace(" ", "")
Example #12
0
def test_infix_5():
    postfix = i2p("5/5")
    assert postfix.replace(" ", "") == "5 5 /".replace(" ", "")
Example #13
0
def test_infix_4():
    postfix = i2p("(5-3)")
    assert postfix.replace(" ", "") == "5 3 -".replace(" ", "")
Example #14
0
def test_infix_3():
    postfix = i2p("7*5")
    assert postfix.replace(" ", "") == "7 5 *".replace(" ", "")
Example #15
0
 def test_infix_5(self):
     postfix = i2p("5/5")
     self.assertEqual(postfix.replace(" ", ""), "5 5 /".replace(" ", ""))
Example #16
0
def test_infix_10():
    postfix = i2p("((8+3)*(2-7))")
    assert postfix.replace(" ", "") == "8 3 + 2 7 - *".replace(" ", "")
Example #17
0
 def test_infix_6(self):
     postfix = i2p("8*5+3")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 5 * 3 +".replace(" ", ""))
Example #18
0
def test_infix_11():
    postfix = i2p("((8+3)*2)-7")
    assert postfix.replace(" ", "") == "8 3 + 2 * 7 -".replace(" ", "")
Example #19
0
 def test_infix_8(self):
     postfix = i2p("8+3*5-7")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 3 5 * + 7 -".replace(" ", ""))
Example #20
0
def test_infix_12():
    postfix = i2p("(8*5)+((3-2)-7*3)")
    assert postfix.replace(" ", "") == "8 5 * 3 2 - 7 3 * - +".replace(" ", "")
Example #21
0
 def test_infix_10(self):
     postfix = i2p("((8+3)*(2-7))")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 3 + 2 7 - *".replace(" ", ""))
Example #22
0
def test_infix_13():
    postfix = i2p("((8*5+3)-7)-(5*3)")
    assert postfix.replace(" ", "") == "8 5 * 3 + 7 - 5 3 * -".replace(" ", "")
Example #23
0
 def test_infix_12(self):
     postfix = i2p("(8*5)+((3-2)-7*3)")
     self.assertEqual(postfix.replace(" ", ""),
                      "8 5 * 3 2 - 7 3 * - +".replace(" ", ""))
Example #24
0
def test_infix_14():
    postfix = i2p("7*9+7-5*6+3-4")
    assert postfix.replace(" ",
                           "") == "7 9 * 7 + 5 6 * - 3 + 4 -".replace(" ", "")
Example #25
0
 def test_infix_14(self):
     postfix = i2p("7*9+7-5*6+3-4")
     self.assertEqual(postfix.replace(" ", ""),
                      "7 9 * 7 + 5 6 * - 3 + 4 -".replace(" ", ""))
Example #26
0
def test_infix_bad_expression():
    with pytest.raises(SyntaxError):
        i2p("(8+3)*(5-6))")
Example #27
0
 def test_infix_2(self):
     postfix = i2p("5  +7")
     self.assertEqual(postfix.replace(" ", ""), "5 7 +".replace(" ", ""))
Example #28
0
def test_infix_bad_param():
    with pytest.raises(ValueError):
        i2p(None)
Example #29
0
 def test_infix_4(self):
     postfix = i2p("(5-3)")
     self.assertEqual(postfix.replace(" ", ""), "5 3 -".replace(" ", ""))
Example #30
0
def test_infix_1():
    postfix = i2p("4")
    assert postfix.replace(" ", "") == "4"