-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterpreter-testing.rkt
144 lines (122 loc) · 8.36 KB
/
interpreter-testing.rkt
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
#lang racket
;;;; Testing of interpreter.rkt
;;;; EECS 345
;;;; Group #7: Shanti Polara, Catlin Campbell, Cormac Dacker
;;;; Run tests by using the test function (test)
(require "interpreter.rkt") ; allows for testing of the interpreter
;; Performs a quick test to see if the test passed or failed and pr(ints info about test if failure
(define pass?
(lambda (actual expected)
(if (equal? actual expected)
(display 'Pass)
(do-nothing (display "Fail {actual} ") (display actual) ; displays info about the failed test
(display " != {expected} ") (display expected)))
(newline)))
;; This function does nothing but allows for all the displays of a failed test to occure without an error
(define do-nothing ; there is probably a better way to do this but ̄\_(ツ)_/̄
(lambda (a b c d)
'())) ; literly does nothing (like what I wish I was doing)
;; Performs all the tests needed to prove the validity of the functions, I love this function.
;; Tests with ";should error" next to them are commented out beacuse they are SUPPOSED to throw errors,
;; which halts the rest of the testing
(define (test)
;Example:
; (diplay "Test #{test number} {test name}") (newline)
; (pass? {actual} {expected})
; (newline)
(test-old-tests-with-classes)
(test-p4-custom-test-scripts)
(test-p4-test-scripts)
) ;left hanging for easy test addition
(define (test-p4-test-scripts)
(display "Test P4 test scripts") (newline)
(display "Test 1: ") (pass? (run "Tests/p4.Test1.txt" "A") 15) ; 1/
(display "Test 2: ") (pass? (run "Tests/p4.Test2.txt" "A") 12) ; 2/
(display "Test 3: ") (pass? (run "Tests/p4.Test3.txt" "A") 125)
(display "Test 4: ") (pass? (run "Tests/p4.Test4.txt" "A") 36)
(display "Test 5: ") (pass? (run "Tests/p4.Test5.txt" "A") 54)
(display "Test 6: ") (pass? (run "Tests/p4.Test6.txt" "A") 110)
;(display "Test 7: ") (pass? (run "Tests/p4.Test7.txt" "C") 26)
;(display "Test 8: ") (pass? (run "Tests/p4.Test8.txt" "Square") 117)
;(display "Test 9: ") (pass? (run "Tests/p4.Test9.txt" "Square") 32)
;(display "Test 10: ") (pass? (run "Tests/p4.Test10.txt" "List") 15)
;(display "Test 11: ") (pass? (run "Tests/p4.Test11.txt" "List") 123456)
;(display "Test 12: ") (pass? (run "Tests/p4.Test12.txt" "List") 5285)
;(display "Test 13: ") (pass? (run "Tests/p4.Test13.txt" "C") -716)
(newline)) ; left hanging for easy test addition
(define (test-p4-custom-test-scripts)
(display "Test P4 custom test scripts") (newline)
(display "Test 1: ") (pass? (run "Tests/Test1.txt" "A") 5)
(display "Test 2: ") (pass? (run "Tests/Test1.txt" "A") 5)
(display "Test 7: ") (pass? (run "Tests/Test7.txt" "A") 110)
(display "Test 8: ") (pass? (run "Tests/Test8.txt" "A") 2)
(newline)) ; left hanging for easy test addition
(define (test-old-tests-with-classes)
(display "Test P1 test scripts") (newline)
(display "Test 1: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test1.txt" "A") 150)
(display "Test 2: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test2.txt" "A") -4)
(display "Test 3: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test3.txt" "A") 10)
(display "Test 4: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test4.txt" "A") 16)
(display "Test 5: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test5.txt" "A") 220)
(display "Test 6: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test6.txt" "A") 5)
(display "Test 7: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test7.txt" "A") 6)
(display "Test 8: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test8.txt" "A") 10)
(display "Test 9: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test9.txt" "A") 5)
(display "Test 10: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test10.txt" "A") -39)
; (display "Test 11: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test11.txt" "A") 150) ; should error
; (display "Test 12: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test12.txt" "A") 150) ; should error
; (display "Test 13: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test13.txt" "A") 150) ; should error
; (display "Test 14: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test14.txt" "A") 150) ; shoule error
(display "Test 15: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test15.txt" "A") 'true)
(display "Test 16: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test16.txt" "A") 100)
(display "Test 17: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test17.txt" "A") 'false)
(display "Test 18: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test18.txt" "A") 'true)
(display "Test 19: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test19.txt" "A") 128)
(display "Test 20: ") (pass? (run "Tests/AdaptedTests/p1.p4.Test20.txt" "A") 12)
(newline)
(display "Test P2 test scripts") (newline)
(display "Test 1: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test1.txt" "A") 20)
(display "Test 2: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test2.txt" "A") 164)
(display "Test 3: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test3.txt" "A") 32)
(display "Test 4: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test4.txt" "A") 2)
; (display "Test 5: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test5.txt" "A") 220) ; should error
(display "Test 6: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test6.txt" "A") 25)
(display "Test 7: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test7.txt" "A") 21)
(display "Test 8: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test8.txt" "A") 6)
(display "Test 9: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test9.txt" "A") -1)
(display "Test 10: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test10.txt" "A") 789)
; (display "Test 11: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test11.txt" "A") 150) ;should error
; (display "Test 12: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test12.txt" "A") 150) ;should error
; (display "Test 13: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test13.txt" "A") 150) ;should error
(display "Test 14: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test14.txt" "A") 12)
(display "Test 15: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test15.txt" "A") 125)
(display "Test 16: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test16.txt" "A") 110)
; (display "Test 17: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test17.txt" "A") 2000400) ; this problem was being a butt
(display "Test 18: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test18.txt" "A") 101)
; (display "Test 19: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test19.txt" "A") 128) ;should error
(display "Test 20: ") (pass? (run "Tests/AdaptedTests/p2.p4.Test20.txt" "A") 112)
(newline)
(display "Test P3 test scripts") (newline)
(display "Test 1: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test1.txt" "A") 10)
(display "Test 2: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test2.txt" "A") 14)
(display "Test 3: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test3.txt" "A") 45)
(display "Test 4: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test4.txt" "A") 55)
; this isn't working because of global vs. local variables
(display "Test 5: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test5.txt" "A") 1)
(display "Test 6: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test6.txt" "A") 115)
(display "Test 7: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test7.txt" "A") 'true)
(display "Test 8: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test8.txt" "A") 20)
(display "Test 9: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test9.txt" "A") 24)
(display "Test 10: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test10.txt" "A") 2)
(display "Test 11: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test11.txt" "A") 35)
; (display "Test 12: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test12.txt" "A") 150) ;should error
(display "Test 13: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test13.txt" "A") 90)
(display "Test 14: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test14.txt" "A") 69)
(display "Test 15: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test15.txt" "A") 87)
(display "Test 16: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test16.txt" "A") 64)
; (display "Test 17: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test17.txt" "A") 2000400) ;should error
(display "Test 18: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test18.txt" "A") 125)
; (display "Test 19: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test19.txt" "A") 100) ; tried to fix, didn't work D:
; this has a similar error as above so it would be very hard to fix
; (display "Test 20: ") (pass? (run "Tests/AdaptedTests/p3.p4.Test20.txt" "A") 2000400)
(newline))