-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanityTests.rkt
105 lines (79 loc) · 2.83 KB
/
sanityTests.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
#lang rosette
(require "interp-enumerate.rkt")
; multiply
(define (num-test1)
(test analyze '(*) 5 '(8 2) '((40 .2)(20 .1))))
; divide
(define (num-test2)
(test analyze '(/) 5 '(4.04 2) '((40.4 10)(18 9))))
; divide
(define (num-test3)
(test analyze '(+) 5 '(50.4 27) '((40.4 10)(18 9))))
; subtract
(define (num-test4)
(test analyze '(-) 5 '(30.4 9) '((40.4 10)(18 9))))
; 3*Col1 + Col2
(define (num-test5)
(test analyze '(* +) 5 '(13 18) '((3 4)(4 6))))
; (Col1 + Col2) * Col3
(define (num-test6)
(test analyze '(* +) 5 '(60 20) '((10 20 2)(4 6 2))))
; (Col1 + Col2) * 5
(define (num-test7)
(test analyze '(* +) 5 '(150 50) '((10 20)(4 6))))
; ceiling
(define (num-test8)
(test analyze '(ceiling) 5 '(26 5) '((25.3)(4.8))))
; quotient
(define (num-test9)
(test analyze '(quotient) 5 '(6 2) '((20 3)(17 8))))
; floor
(define (num-test10)
(test analyze '(floor) 5 '(-43 4) '((-42.8)(4.8))))
; sign
(define (num-test11)
(test analyze '('sign) 5 '(1 0 -1) '((42.8) (0) (-4.8))))
; truncate
(define (num-test12)
(test analyze '(truncate) 5 '(42 -4) '((42.8)(-4.8))))
; remainder
(define (num-test13)
(test analyze '(remainder) 5 '(2 3) '((20 3)(13 5))))
; test whether floats are dealt with correctly
(define (num-test14)
(test analyze '(*) 5 '(60.77916 1.485) '((4.563 13.32) (4.5 .33))))
; max
(define (agg-1)
(test aggregate '(max) 5 '(1 2 3) '((1)(2)(3))))
; max (+ in1 1)
(define (agg-2)
(test aggregate '(max +) 5 '(2 3 4) '((1)(2)(3))))
; string-append concat
(define (agg-3)
(test aggregate '(string-append concat) 5 '("aa" "aabb" "aabbcc") '(("a")("b")("c"))))
; string-append substring
(define (agg-4)
(test aggregate '(string-append substring) 5 '("aa" "aabb" "aabbcc") '(("aax")("bbx")("ccx"))))
; Sum(Col1 - (Col1 * Col2))
(define (agg-5)
(test aggregate '(+ - *) 5 '(9 27) '((10 .1)(20 .1))))
; this next one does not work and I dont know why
;(println (aggregate 5 '(9.45 27.05) '(10 .1 .05) '(20 .2 .1)))
; compare to for strings
(define (test-str1)
(test analyze '(==) 5 '(#t #f #f) '(("A" "A")("A" "AA")("A" "D"))))
; and for boolean operations
(define (test-logic-and)
(test analyze '(and ==) 5 '(#t #f #f) '(("A" "D")("A" "G")("F" "D"))))
; or for boolean expression
(define (test-logic-or)
(test analyze '(or ==) 5 '(#t #t #t #f) '(("A" "D")("A" "G")("F" "D")("F" "G"))))
; if then else expression
(define (test-if-then-else1)
(test analyze '(== if) 5 '("C" "D") '(("A")("B"))))
; not expression
(define (test-if-not)
(test analyze '(not ==) 5 '(#t #t #f) '(("C")("B")("A"))))
(define (num-testAll)
(begin (num-test1) (num-test2) (num-test3) (num-test4) (num-test5) (num-test6) (num-test7) (num-test8) (num-test9) (num-test10) (num-test11) (num-test12) (num-test13) (num-test14) (agg-1)
(agg-2) (agg-3) (agg-4) (agg-5) (test-str1) (test-logic-and) (test-logic-or)(test-if-then-else1)))