예제 #1
0
 def test_load_the_language(self):
     env = _load_the_language()
     envd = dict(env)
     definitions_of_one_param = (
         "not null cadr caddr caar cadar caddar").split()
     definitions_of_two_params = ("and list").split()
     fixpoints_of_two_params = (
         "append assoc eval evcon evlis pair").split()
     predefines = definitions_of_one_param \
         + definitions_of_two_params \
         + fixpoints_of_two_params
     self.assertEqual(len(envd), len(predefines))
     # Every definition is a lambda construction with a list as body
     for atom in definitions_of_one_param + definitions_of_two_params:
         e = envd[atom]
         self.assertEqual(len(e), 3)
         self.assertEqual(e[0], "lambda")
         self.assertTrue(isinstance(e[1], tuple))
         self.assertTrue(isinstance(e[2], tuple))
     for atom in definitions_of_one_param:
         e = envd[atom]
         self.assertEqual(len(e[1]), 1)
     for atom in definitions_of_two_params:
         e = envd[atom]
         self.assertEqual(len(e[1]), 2)
     for atom in fixpoints_of_two_params:
         e = envd[atom]
         self.assertEqual(len(e), 3)
         self.assertEqual(e[0], "label")
         self.assertEqual(len(e[2]), 3)
         self.assertEqual(e[2][0], "lambda")
         self.assertEqual(len(e[2][1]), 2)
예제 #2
0
 def do_not_test_evcon(self):
     env = _load_the_language()
     e = evcon_( ((("quote", "a"), ("quote", "a")), (("quote", "t"), ("quote", "it is t"))), env)
     self.assertEqual(e, "it is t")
     env1 = append_(
         (('f', 'atom'), ('l', (("j"), ('u', 'v'), 'w')), ('map_f_over_l', ('label', 'map_f_over_l', ('lambda', ('f', 'l'), ('cond', ((("trace", ('null', 'l')), ('quote', ())), (('quote', 't'), ('cons', ('f', ('car', 'l')), ("trace", ('map_f_over_l', 'f', ('cdr', 'l'))))))))))),
         env,
     )
     e = evcon_( ((('null', 'l'), ('quote', ())), (('quote', 't'), ('cons', ('f', ('car', 'l')), ('map_f_over_l', 'f', ('cdr', 'l'))))), env1)
     self.assertEqual(e, ("t", (), "t"))
예제 #3
0
 def do_not_test_evcon(self):
     env = _load_the_language()
     e = evcon_(((("quote", "a"), ("quote", "a")),
                 (("quote", "t"), ("quote", "it is t"))), env)
     self.assertEqual(e, "it is t")
     env1 = append_(
         (('f', 'atom'), ('l', (("j"), ('u', 'v'), 'w')),
          ('map_f_over_l',
           ('label', 'map_f_over_l',
            ('lambda', ('f', 'l'),
             ('cond', ((("trace", ('null', 'l')), ('quote', ())),
                       (('quote', 't'), ('cons', ('f', ('car', 'l')),
                                         ("trace", ('map_f_over_l', 'f',
                                                    ('cdr', 'l'))))))))))),
         env,
     )
     e = evcon_(((('null', 'l'), ('quote', ())),
                 (('quote', 't'), ('cons', ('f', ('car', 'l')),
                                   ('map_f_over_l', 'f', ('cdr', 'l'))))),
                env1)
     self.assertEqual(e, ("t", (), "t"))
예제 #4
0
 def test_load_the_language(self):
     env = _load_the_language()
     envd = dict(env)
     definitions_of_one_param = (
         "not null cadr caddr caar cadar caddar"
     ).split()
     definitions_of_two_params = (
         "and list"
     ).split()
     fixpoints_of_two_params = (
         "append assoc eval evcon evlis pair"
     ).split()
     predefines = definitions_of_one_param \
         + definitions_of_two_params \
         + fixpoints_of_two_params
     self.assertEqual(len(envd), len(predefines))
     # Every definition is a lambda construction with a list as body
     for atom in definitions_of_one_param + definitions_of_two_params:
         e = envd[atom]
         self.assertEqual(len(e), 3)
         self.assertEqual(e[0], "lambda")
         self.assertTrue(isinstance(e[1], tuple))
         self.assertTrue(isinstance(e[2], tuple))
     for atom in definitions_of_one_param:
         e = envd[atom]
         self.assertEqual(len(e[1]), 1)
     for atom in definitions_of_two_params:
         e = envd[atom]
         self.assertEqual(len(e[1]), 2)
     for atom in fixpoints_of_two_params:
         e = envd[atom]
         self.assertEqual(len(e), 3)
         self.assertEqual(e[0], "label")
         self.assertEqual(len(e[2]), 3)
         self.assertEqual(e[2][0], "lambda")
         self.assertEqual(len(e[2][1]), 2)