Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)