def test_normalize_exchange_1(self): sequence = [2, 1, '+'] expected = [1, 2, '+'] sf = SuffixFormula() for s in sequence: sf.push(s) new_seq = sf._normalize_exchange(sequence) self.assertEqual(new_seq, expected)
def test_normalize_exchange_2(self): # (1 + 2) * (3 + 4) => 1 2 + 3 4 + * sequence = [1, 2, '+', 3, 4, '+', '*'] sf = SuffixFormula() for s in sequence: sf.push(s) new_seq = sf._normalize_exchange(sequence) self.assertEqual(new_seq, sequence)
def test_normalize_exchange_3(self): # (4 + 3) * (2 + 1) => 4 3 + 2 1 + * # (1 + 2) * (3 + 4) => 1 2 + 3 4 + * sequence = [4, 3, '+', 2, 1, '+', '*'] expected = [1, 2, '+', 3, 4, '+', '*'] sf = SuffixFormula() for s in sequence: sf.push(s) new_seq = sf._normalize_exchange(sequence) self.assertEqual(new_seq, expected)