-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_prelude.py
54 lines (44 loc) · 1.23 KB
/
test_prelude.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import unittest
import visp
import test_visp
class TestPrelude(test_visp.TestCase):
def test_car(self):
self.assertEvalEqual(
"(car '(1 2 3))",
"1")
def test_cdr(self):
self.assertEvalEqual(
"(cdr '(1 2 3))",
"'(2 3)")
def test_caar(self):
self.assertEvalEqual(
"(caar '((1 2) (3 4) (5 6)))",
"1")
def test_cadr(self):
self.assertEvalEqual(
"(cadr '((1 2) (3 4) (5 6)))",
"'(3 4)")
def test_cdar(self):
self.assertEvalEqual(
"(cdar '((1 2) (3 4) (5 6)))",
"'(2)")
def test_cddr(self):
self.assertEvalEqual(
"(cddr '((1 2) (3 4) (5 6)))",
"'((5 6))")
def test_nullq_nil(self):
self.assertEvalEqual(
"(null? '())",
"#t")
def test_nullq_list(self):
self.assertEvalEqual(
"(null? '(1 2 3))",
"#f")
def test_cons(self):
self.assertEvalEqual(
"(cons 1 (cons 2 (cons 3 4)))",
"'(1 2 3 . 4)")
def test_map(self):
self.assertEvalEqual(
"(map (lambda (x) (+ x 1)) '(1 2 3 4 5))",
"'(2 3 4 5 6)")