def test_normalize_remove_brackets_2(self): # 6 + (5 + 5 * 6) => 6 5 5 6 * + + # 6 + 5 + 5 * 6 => 6 5 + 5 6 * + sequence = [6, 5, 5, 6, '*', '+', '+'] expected = [6, 5, '+', 5, 6, '*', '+'] sf = SuffixFormula() for s in sequence: sf.push(s) new_seq = sf._normalize_remove_brackets(sequence, '+') self.assertEqual(new_seq, expected)
def test_normalize_remove_brackets_1(self): # 6 * (5 + (5 - 6)) => 6 5 5 6 - + * # 6 * (5 + 5 - 6) => 6 5 5 + 6 - * sequence = [6, 5, 5, 6, '-', '+', '*'] expected = [6, 5, 5, '+', 6, '-', '*'] sf = SuffixFormula() for s in sequence: sf.push(s) new_seq = sf._normalize_remove_brackets(sequence, '+') self.assertEqual(new_seq, expected)