This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path052num.test
139 lines (105 loc) · 2.53 KB
/
052num.test
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
(test "arithmetic is varargs"
:valueof (+ 1 2 3 (* 1 2 2))
:should be 10)
(test "unary negation works"
:valueof (- 3)
:should be -3)
(test "division works"
:valueof (/ 4 2 2)
:should be 1)
(test "increment works with lexical vars"
:valueof (ret x 3 ++x)
:should be 4)
(test "divides works"
:valueof (divides 3 2)
:should be_false)
(test "divides works - 2"
:valueof (divides 4 2)
:should be_true)
(test "comparing anything to false always fails"
:valueof (< 3 false)
:should be_false)
(test "> works"
:valueof (> 3 2 1)
:should be_true)
(test "> works - 2"
:valueof (> 3 1 2)
:should be_false)
(test "< works"
:valueof (< 3 1 2)
:should be_false)
(test "< works - 2"
:valueof (< 1 2 3)
:should be_true)
(test "< works inside if"
:valueof (if (3 < 0) 34 35)
:should be 35)
(test "<= works"
:valueof (<= 1 2 3)
:should be_true)
(test "<= works - 2"
:valueof (<= 1 1 3)
:should be_true)
(test "<= works - 3"
:valueof (<= 1 4 3)
:should be_false)
(test "<= fails on nil"
:valueof (<= 1 nil 3)
:should be_false)
(test ">= works"
:valueof (>= 3 2 1)
:should be_true)
(test ">= works - 2"
:valueof (>= 3 1 1)
:should be_true)
(test ">= works - 3"
:valueof (>= 3 1 2)
:should be_false)
(test ">= fails on nil"
:valueof (>= 4 nil 3)
:should be_false)
(test "max works"
:valueof (max 0 5 7 9 3 4 21 15)
:should be 21)
(test "< works with scorer"
:valueof ((< (fn(_) _%3)) 4 2)
:should be_true)
(test "< works with scorer - 2"
:valueof ((< (fn(_) _%3)) 2 4)
:should be_false)
(test "< returns unscored value on success"
:valueof ((< car) '(1 2) '(3 4))
:should be '(3 4))
(test "> works with scorer"
:valueof ((> abs) -6 2)
:should be_true)
(test "> works with scorer - 2"
:valueof ((> abs) 3 -6)
:should be_false)
(test "sort works"
:valueof (sort (<) '(1 12 3))
:should be '(1 3 12))
(test "sort works with scorer"
:valueof (sort (< (fn(_) _%3)) '(5 7 6)) # modulo sort
:should be '(6 7 5))
(test "sort works on lists"
:valueof (sort (< car) '((2 1) (3 2) (1 3)))
:should be '((1 3) (2 1) (3 2)))
(test "floats compare to within a tolerance"
:valueof (2 >= 2.0000001)
:should be_true)
(test "sum works with zero args"
:valueof (sum nil)
:should be 0)
(test "sum works with one arg"
:valueof (sum '(2))
:should be 2)
(test "sum works with multiple args"
:valueof (sum '(1 2 3))
:should be 6)
(test "range checks work"
:valueof (1 <= 1 <= 2)
:should be_true)
(test "range checks work - 2"
:valueof (3 >= 2 > 2)
:should be_false)