-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.ss
81 lines (77 loc) · 2.76 KB
/
tester.ss
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
;; Team Othello
;; tester.ss
;; October 4, 2010
(define othello-math-tester
(list '((my-zero? 0) #t)
'((my-zero? 1) #f)
'((my-positive? 1) #t)
'((my-positive? -1) #f)
'((my-negative? -1) #t)
'((my-negative? 1) #f)
'((my-even? 2) #t)
'((my-even? 1) #f)
'((my-odd? 1) #t)
'((my-odd? 1.5) "oops!")
'((my-odd? 2) #f)
'((my-div 17 3) 5)
'((my-div 17 -3) -5)
'((my-div -17 3) -6)
'((my-div -17 -3) 6)
'((my-mod 17 3) 2)
'((my-mod 17 -3) 2)
'((my-mod -17 3) 1)
'((my-mod -17 -3) 1)
'((my-truncate 5.7) 5.0)
'((my-truncate -5.7) -5.0)
'((my-floor 5.7) 5.0)
'((my-floor -5.7) -6.0)
'((my-ceiling 5.7) 6.0)
'((my-ceiling -5.7) -5.0)
'((my-round 5.7) 6.0)
'((my-round -5.7) -6.0)
'((my-round 5.5) 6.0)
'((my-round 4.5) 4.0)
'((my-abs 4) 4)
'((my-abs -4) 4)
'((my-max 2 9 -4) 9)
'((my-min 2 9 -4) -4)
'((my-gcd 3 6 -12) 3)
'((my-lcm 3 6 -9) 18)
'((my-expt -2 3) -8)
'((my-expt -2 -3) -1/8)
'((my-expt 0 0) 1)))
(define othello-list-tester
(list '((my-caar '((1 2) (3 4) (5 6) (7 8))) 1)
'((my-cadr '((1 2) (3 4) (5 6) (7 8))) (3 4))
'((my-cadar '((1 2 3) (4 5 6) (7 8 9))) 2)
'((my-cdddar '((1 2 3 4) (4 5 6) (7 8))) (4)) ;we also have all permutations up to 4 car/cdr
'((my-list 1 2 3) (1 2 3))
'((my-list) ())
'((my-length '(1 2 3 4)) 4)
'((my-length '()) 0)
'((my-list-tail '(0 1 2 3 4) 3) (3 4))
'((my-member 'a '(1 2 3 a b c)) (a b c))
'((my-member 'z '(1 2 3 a b c)) #f)
'((my-assq 2 '((0 a) (1 b) (2 c) (3 d))) (2 c))
'((my-assq -3 '((0 a) (1 b) (2 c) (3 d))) #f)
'((my-map (lambda (x) (* x x)) '(1 2 3)) (1 4 9))
'((my-append '(a b) '(c d)) (a b c d))
'((my-append '(a b) 'c) (a b . c))
'((my-reverse '(1 2 3)) (3 2 1))
'((my-list? (cons 1 2)) #f)
'((my-list? (cons 1 '(2 3))) #t)
'((my-list-ref '(1 2 3 4 5) 3) 4)
'((my-cons* 1 2 3 '(4 5)) (1 2 3 4 5))
'((my-cons* 3) 3)
'((my-memp even? '(1 2 3)) (2 3))
'((my-remq 2 '(1 2 3 2 4 5)) (1 3 4 5))
'((my-remp even? '(1 2 3 4 5)) (1 3 5))
'((my-filter even? '(1 2 3 4 5)) (2 4))
'((my-find even? '(1 2 3 4 5)) 2)
'((my-assp even? '((1 a) (2 b) (3 c))) (2 b))))
;; call to test math.ss
;;(equal? (map eval (map car othello-math-tester)) (map cadr othello-math-tester))
;; calls to test lists.ss
;;(equal? (map eval (map car othello-list-tester)) (map cadr othello-list-tester))
;;(map eval (map car othello-list-tester))
;;(map cadr othello-list-tester)