|
168 | 168 | (test:expect (< (math:abs (- (math:complex-module c4) 12.649110640673517)) 0.0001)) }) |
169 | 169 |
|
170 | 170 | (test:case "vectors" { |
171 | | - (test:eq 32 (math:dotProduct [1 2 3] [4 5 6])) |
172 | | - (test:eq 3 (math:dotProduct [1 3 -5] [4 -2 -1])) }) |
| 171 | + (test:eq (math:dotProduct [1 2 3] [4 5 6]) 32) |
| 172 | + (test:eq (math:dotProduct [1 3 -5] [4 -2 -1]) 3) }) |
173 | 173 |
|
174 | 174 | (test:case "improvementRatioPercentage" { |
175 | | - (test:eq 0 (math:improvementRatioPercentage 12 12)) |
176 | | - (test:eq 100 (math:improvementRatioPercentage 24 12)) |
177 | | - (test:eq 50 (math:improvementRatioPercentage 18 12)) }) }) |
| 175 | + (test:eq (math:improvementRatioPercentage 12 12) 0) |
| 176 | + (test:eq (math:improvementRatioPercentage 24 12) 100) |
| 177 | + (test:eq (math:improvementRatioPercentage 18 12) 50) }) |
| 178 | + |
| 179 | + (test:case "copySign" { |
| 180 | + (test:eq (math:copySign 0) 1) |
| 181 | + (test:eq (math:copySign -1) -1) |
| 182 | + (test:eq (math:copySign math:Inf) 1) }) |
| 183 | + |
| 184 | + (test:case "degrees, radians" { |
| 185 | + (test:eq (math:degrees (math:radians 0)) 0) |
| 186 | + (test:eq (math:degrees (math:radians 20)) 20) |
| 187 | + (test:eq (math:degrees (math:radians 40)) 40) |
| 188 | + (test:eq (math:degrees (math:radians 70)) 70) |
| 189 | + (test:eq (math:degrees (math:radians 70)) 70) |
| 190 | + (test:eq (math:degrees (math:radians 90)) 90) |
| 191 | + (test:eq (math:degrees math:pi) 180) |
| 192 | + (test:eq (math:degrees (/ math:pi 2)) 90) |
| 193 | + (test:eq (math:radians 180) math:pi) |
| 194 | + (test:eq (math:radians 90) (/ math:pi 2)) }) |
| 195 | + |
| 196 | + (test:case "integer?" { |
| 197 | + (test:expect (math:integer? 0)) |
| 198 | + (test:expect (math:integer? 10.0)) |
| 199 | + (test:expect (math:integer? -1)) |
| 200 | + (test:expect (math:integer? math:Inf)) |
| 201 | + (test:expect (not (math:integer? 1.5))) |
| 202 | + (test:expect (not (math:integer? 0.5))) |
| 203 | + (test:expect (not (math:integer? -0.5))) |
| 204 | + (test:expect (not (math:integer? -1.5))) }) |
| 205 | + |
| 206 | + (test:case "factorial" { |
| 207 | + (test:eq (math:factorial -10) 0) |
| 208 | + (test:eq (math:factorial 0) 1) |
| 209 | + (test:eq (math:factorial 1) 1) |
| 210 | + (test:eq (math:factorial 2) 2) |
| 211 | + (test:eq (math:factorial 3) 6) |
| 212 | + (test:eq (math:factorial 4) 24) |
| 213 | + (test:eq (math:factorial 5) 120) }) |
| 214 | + |
| 215 | + (test:case "binomialCoeff" { |
| 216 | + (test:eq (math:binomialCoeff 4 6) 0) |
| 217 | + (test:eq (math:binomialCoeff 10 10) 1) |
| 218 | + (test:eq (math:binomialCoeff 4 0) 1) |
| 219 | + (test:eq (math:binomialCoeff 4 1) 4) |
| 220 | + (test:eq (math:binomialCoeff 4 2) 6) |
| 221 | + (test:eq (math:binomialCoeff 4 3) 4) |
| 222 | + (test:eq (math:binomialCoeff 4 4) 1) }) |
| 223 | + |
| 224 | + (test:case "permutations" { |
| 225 | + (test:eq (math:permutations 5 3) 60) |
| 226 | + (test:eq (math:permutations 6 1) 6) |
| 227 | + (test:eq (math:permutations 6 2) 30) |
| 228 | + (test:eq (math:permutations 6 3) 120) |
| 229 | + (test:eq (math:permutations 6 4) 360) |
| 230 | + (test:eq (math:permutations 6 5) 720) |
| 231 | + (test:eq (math:permutations 6 6) 720) }) |
| 232 | + |
| 233 | + (test:case "close?" { |
| 234 | + (test:expect (math:close? 1 1)) |
| 235 | + (test:expect (math:close? 0.99999999 1)) |
| 236 | + (test:expect (not (math:close? 0.9999999 1))) |
| 237 | + (test:expect (not (math:close? 2 1))) |
| 238 | + (test:expect (not (math:close? 1.5 1))) }) |
| 239 | + |
| 240 | + (test:case "euclideanDistance" { |
| 241 | + (test:eq (math:euclideanDistance [1] [1]) 0) |
| 242 | + (test:eq (math:euclideanDistance [1] [2]) 1) |
| 243 | + (test:expect (math:close? (math:euclideanDistance [0 0] [3 4]) 5)) }) |
| 244 | + |
| 245 | + (test:case "gcd, lcm" { |
| 246 | + (test:eq (math:gcd 48 18) 6) |
| 247 | + (test:eq (math:gcd 18 48) 6) |
| 248 | + (test:eq (math:gcd 42 56) 14) |
| 249 | + |
| 250 | + (test:eq (math:lcm 4 6) 12) |
| 251 | + (test:eq (math:lcm 48 180) 720) }) |
| 252 | +}) |
0 commit comments