-
Notifications
You must be signed in to change notification settings - Fork 1
/
tester.scm
159 lines (146 loc) · 4.9 KB
/
tester.scm
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#lang racket
(require "interpreter.scm")
(require "classParser.scm")
;(require (planet jowalsh/code-coverage))
; Tester
; General testing framework
(define test
(lambda (filename expected-output)
(if (eq? (interpret filename (findmain (parser filename))) expected-output)
(string-append "Passed " filename)
(string-append "Failed " filename
", ! Expected output: " (if (number? expected-output)
(number->string expected-output)
(symbol->string expected-output))
", Interpreter output: " (if (number? (interpret filename (findmain (parser filename))))
(number->string (interpret filename (findmain (parser filename))))
(symbol->string (interpret filename (findmain (parser filename)))))))))
(define member*
(lambda (x lis)
(cond
((null? lis) #f)
((not (list? lis)) (equal? x lis))
(else (or (member* x (car lis)) (member* x (cdr lis)))))))
(define findmain
(lambda (parse-tree)
(cond
((null? parse-tree) (error "could not find main"))
((member* 'main (car parse-tree)) (cadr (car parse-tree)))
(else (findmain (cdr parse-tree))))))
; Tests 1
(newline)(newline)
(print " TESTS for Project 1 ")
(newline)
(test "Tests/1/test1.java" 150)
(test "Tests/1/test2.java" -4)
(test "Tests/1/test3.java" 10)
(test "Tests/1/test4.java" 16)
(test "Tests/1/test5.java" 220)
(test "Tests/1/test6.java" 5)
(test "Tests/1/test7.java" 6)
(test "Tests/1/test8.java" 10)
(test "Tests/1/test9.java" 5)
(test "Tests/1/test10.java" -39)
(test "Tests/1/test11.java" `error)
(test "Tests/1/test12.java" `error)
(test "Tests/1/test13.java" `error)
(test "Tests/1/test14.java" `error)
(test "Tests/1/test15.java" `true)
(test "Tests/1/test16.java" 100)
(test "Tests/1/test17.java" `false)
(test "Tests/1/test18.java" `true)
(test "Tests/1/test19.java" 128)
(test "Tests/1/test20.java" 12)
(test "Tests/1/test21.java" 30)
(test "Tests/1/test22.java" 11)
(test "Tests/1/test23.java" 1106)
(test "Tests/1/test24.java" 12)
(test "Tests/1/test25.java" 16)
(test "Tests/1/test26.java" 72)
(test "Tests/1/test27.java" 21)
(test "Tests/1/test28.java" 164)
; Tests 2
(newline)(newline)
(print " TESTS for Project 2 ")
(newline)
(test "Tests/2/test1.java" 20)
(test "Tests/2/test2.java" 164)
(test "Tests/2/test3.java" 32)
(test "Tests/2/test4.java" 2)
(test "Tests/2/test5.java" `error)
(test "Tests/2/test6.java" 25)
(test "Tests/2/test7.java" 21)
(test "Tests/2/test8.java" 6)
(test "Tests/2/test9.java" (- 1))
(test "Tests/2/test10.java" 789)
(test "Tests/2/test11.java" `error)
(test "Tests/2/test12.java" `error)
(test "Tests/2/test13.java" `error)
(test "Tests/2/test14.java" 12)
(test "Tests/2/test15.java" 125)
(test "Tests/2/test16.java" 110)
(test "Tests/2/test17.java" 2000400)
(test "Tests/2/test18.java" 101)
(test "Tests/2/test19.java" `error)
(test "Tests/2/test20.java" 21)
; Tests 3
(newline)(newline)
(print " TESTS for Project 3 ")
(newline)
(test "Tests/3/test1.java" 10)
(test "Tests/3/test2.java" 14)
(test "Tests/3/test3.java" 45)
(test "Tests/3/test4.java" 55)
(test "Tests/3/test5.java" 1)
(test "Tests/3/test6.java" 115)
(test "Tests/3/test7.java" `true)
(test "Tests/3/test8.java" 20)
(test "Tests/3/test9.java" 24)
(test "Tests/3/test10.java" 2)
(test "Tests/3/test11.java" 35)
(test "Tests/3/test12.java" `error)
(test "Tests/3/test13.java" 90)
(test "Tests/3/test14.java" 69)
(test "Tests/3/test15.java" 87)
(test "Tests/3/test16.java" 64)
(test "Tests/3/test17.java" `error) ; Error: b out of scope
(test "Tests/3/test18.java" 125)
(test "Tests/3/test19.java" 100)
(test "Tests/3/test20.java" 2000400)
(test "Tests/3/test21.java" 3421)
(test "Tests/3/test22.java" 20322)
(test "Tests/3/test23.java" 21)
; Tests 4
(newline)(newline)
(print " TESTS for Project 4 ")
(newline)
(test "Tests/4/test1.java" 15)
(test "Tests/4/test2.java" 12)
(test "Tests/4/test3.java" 125)
(test "Tests/4/test4.java" 36)
(test "Tests/4/test5.java" 54)
(test "Tests/4/test6.java" 110)
(test "Tests/4/test7.java" 26)
(test "Tests/4/test8.java" 117)
(test "Tests/4/test9.java" 32)
(test "Tests/4/test10.java" 15)
(test "Tests/4/test11.java" 123456)
(test "Tests/4/test12.java" 12)
(test "Tests/4/test13.java" (- 716))
(test "Tests/4/test21.java" 530)
(test "Tests/4/test22.java" 66)
(test "Tests/4/test23.java" 1026)
(test "Tests/4/test24.java" 2045)
(test "Tests/4/test31.java" 20)
(test "Tests/4/test32.java" 530)
(test "Tests/4/test33.java" 615)
(test "Tests/4/test34.java" 16)
(test "Tests/4/test35.java" 100)
(test "Tests/4/test36.java" 420)
(test "Tests/4/test37.java" `error)
(test "Tests/4/test41.java" 300)
(test "Tests/4/test42.java" `error)
(test "Tests/4/test51.java" 417)
(test "Tests/4/test52.java" 10)
(test "Tests/4/test53.java" 48)
(test "Tests/4/test54.java" 1629)