Example #1
0
 def test_08(self):
     self.assertEqual(quiz.constant_fold(('+', 'x', ('+', 'x', 'x'))),
                      ('+', 'x', ('+', 'x', 'x')))
Example #2
0
 def test_06(self):
     self.assertEqual(quiz.constant_fold(('*', 'a', ('-', 'b', 0))),
                      ('*', 'a', 'b'))
Example #3
0
 def test_07(self):
     self.assertEqual(quiz.constant_fold(('+', 1, ('*', 2, ('-', 3, 2)))),
                      3)
Example #4
0
 def test_05(self):
     self.assertEqual(
         quiz.constant_fold(('+', 7, ('*', 'x', ('-', 7, ('+', 4, 3))))), 7)
Example #5
0
 def test_04(self):
     self.assertEqual(
         quiz.constant_fold(('*', 1, ('+', 0, ('*', ('+', 'x', 0), 1)))),
         'x')
Example #6
0
 def test_03(self):
     self.assertEqual(
         quiz.constant_fold(('+', 'a', ('+', ('*', 'b', 0), 'c'))),
         ('+', 'a', 'c'))
Example #7
0
 def test_02(self):
     self.assertEqual(
         quiz.constant_fold(('+', 'a', ('+', ('*', ('+', 3, 5), 6), 'b'))),
         ('+', 'a', ('+', 48, 'b')))
Example #8
0
 def test_01(self):
     self.assertEqual(
         quiz.constant_fold(
             ('+', 'a', ('+', 'b', ('+', ('+', 3, 5), 'c')))),
         ('+', 'a', ('+', 'b', ('+', 8, 'c'))))