| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'math-trace-tests.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 'none'; |
| 9 |
var summary = 'trace-capability math mini-testsuite'; |
| 10 |
|
| 11 |
printBugNumber(BUGNUMBER); |
| 12 |
printStatus (summary); |
| 13 |
|
| 14 |
jit(true); |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
const haveTracemonkey = !!(this.tracemonkey) |
| 24 |
const HOTLOOP = haveTracemonkey ? tracemonkey.HOTLOOP : 2; |
| 25 |
|
| 26 |
const RECORDLOOP = HOTLOOP; |
| 27 |
|
| 28 |
const RUNLOOP = HOTLOOP + 1; |
| 29 |
|
| 30 |
var testName = null; |
| 31 |
if ("arguments" in this && arguments.length > 0) |
| 32 |
testName = arguments[0]; |
| 33 |
var fails = [], passes=[]; |
| 34 |
|
| 35 |
function jitstatHandler(f) |
| 36 |
{ |
| 37 |
if (!haveTracemonkey) |
| 38 |
return; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
f("recorderStarted"); |
| 43 |
f("recorderAborted"); |
| 44 |
f("traceCompleted"); |
| 45 |
f("sideExitIntoInterpreter"); |
| 46 |
f("typeMapMismatchAtEntry"); |
| 47 |
f("returnToDifferentLoopHeader"); |
| 48 |
f("traceTriggered"); |
| 49 |
f("globalShapeMismatchAtEntry"); |
| 50 |
f("treesTrashed"); |
| 51 |
f("slotPromoted"); |
| 52 |
f("unstableLoopVariable"); |
| 53 |
f("noCompatInnerTrees"); |
| 54 |
f("breakLoopExits"); |
| 55 |
f("returnLoopExits"); |
| 56 |
} |
| 57 |
|
| 58 |
function test(f) |
| 59 |
{ |
| 60 |
if (!testName || testName == f.name) { |
| 61 |
|
| 62 |
var localJITstats = {}; |
| 63 |
jitstatHandler(function(prop, local, global) { |
| 64 |
localJITstats[prop] = tracemonkey[prop]; |
| 65 |
}); |
| 66 |
check(f.name, f(), f.expected, localJITstats, f.jitstats); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
function map_test(t, cases) |
| 71 |
{ |
| 72 |
for (var i = 0; i < cases.length; i++) { |
| 73 |
function c() { return t(cases[i].input); } |
| 74 |
c.expected = cases[i].expected; |
| 75 |
c.name = t.name + "(" + uneval(cases[i].input) + ")"; |
| 76 |
test(c); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
function close_enough(expected, actual) |
| 88 |
{ |
| 89 |
if (typeof expected != typeof actual) |
| 90 |
return false; |
| 91 |
if (typeof expected != 'number') |
| 92 |
return actual == expected; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
if (actual != actual) |
| 97 |
return expected != expected |
| 98 |
if (expected != expected) |
| 99 |
return false; |
| 100 |
|
| 101 |
|
| 102 |
if (actual != expected) |
| 103 |
return Math.abs(actual - expected) <= 1E-10; |
| 104 |
|
| 105 |
|
| 106 |
if (actual == 0) |
| 107 |
return (1 / actual > 0) == (1 / expected > 0); |
| 108 |
|
| 109 |
return true; |
| 110 |
} |
| 111 |
|
| 112 |
function check(desc, actual, expected, oldJITstats, expectedJITstats) |
| 113 |
{ |
| 114 |
var pass = false; |
| 115 |
if (close_enough(expected, actual)) { |
| 116 |
pass = true; |
| 117 |
jitstatHandler(function(prop) { |
| 118 |
if (expectedJITstats && prop in expectedJITstats && |
| 119 |
expectedJITstats[prop] != |
| 120 |
tracemonkey[prop] - oldJITstats[prop]) { |
| 121 |
pass = false; |
| 122 |
} |
| 123 |
}); |
| 124 |
if (pass) { |
| 125 |
reportCompare(expected, actual, desc); |
| 126 |
passes.push(desc); |
| 127 |
return print(desc, ": passed"); |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
if (expected instanceof RegExp) { |
| 132 |
pass = reportMatch(expected, actual + '', desc); |
| 133 |
if (pass) { |
| 134 |
jitstatHandler(function(prop) { |
| 135 |
if (expectedJITstats && prop in expectedJITstats && |
| 136 |
expectedJITstats[prop] != |
| 137 |
tracemonkey[prop] - oldJITstats[prop]) { |
| 138 |
pass = false; |
| 139 |
} |
| 140 |
}); |
| 141 |
} |
| 142 |
if (pass) { |
| 143 |
passes.push(desc); |
| 144 |
return print(desc, ": passed"); |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
reportCompare(expected, actual, desc); |
| 149 |
|
| 150 |
fails.push(desc); |
| 151 |
var expectedStats = ""; |
| 152 |
if (expectedJITstats) { |
| 153 |
jitstatHandler(function(prop) { |
| 154 |
if (prop in expectedJITstats) { |
| 155 |
if (expectedStats) |
| 156 |
expectedStats += " "; |
| 157 |
expectedStats += |
| 158 |
prop + ": " + expectedJITstats[prop]; |
| 159 |
} |
| 160 |
}); |
| 161 |
} |
| 162 |
var actualStats = ""; |
| 163 |
if (expectedJITstats) { |
| 164 |
jitstatHandler(function(prop) { |
| 165 |
if (prop in expectedJITstats) { |
| 166 |
if (actualStats) |
| 167 |
actualStats += " "; |
| 168 |
actualStats += prop + ": " + (tracemonkey[prop]-oldJITstats[prop]); |
| 169 |
} |
| 170 |
}); |
| 171 |
} |
| 172 |
print(desc, ": FAILED: expected", typeof(expected), |
| 173 |
"(", uneval(expected), ")", |
| 174 |
(expectedStats ? " [" + expectedStats + "] " : ""), |
| 175 |
"!= actual", |
| 176 |
typeof(actual), "(", uneval(actual), ")", |
| 177 |
(actualStats ? " [" + actualStats + "] " : "")); |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
function testmath(funcname, args, expected) { |
| 190 |
var i, j; |
| 191 |
|
| 192 |
var arg_value_list = eval("[" + args + "]"); |
| 193 |
var arity = arg_value_list.length; |
| 194 |
|
| 195 |
|
| 196 |
var actuals = [] |
| 197 |
for (i = 0; i < arity; i++) |
| 198 |
actuals.push("a[i][" + i + "]"); |
| 199 |
actuals = actuals.join(","); |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
var mapfunc = eval("(function(a) {\n" |
| 206 |
+ " for (var i = 0; i < a.length; i++)\n" |
| 207 |
+ " a[i] = " + funcname + "(" + actuals +");\n" |
| 208 |
+ " })\n"); |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
var dummies_and_input = []; |
| 215 |
for (i = 0; i < RUNLOOP; i++) { |
| 216 |
var dummy_list = []; |
| 217 |
for (j = 0; j < arity; j++) |
| 218 |
dummy_list[j] = .0078125 * ((i + j) % 128); |
| 219 |
dummies_and_input[i] = dummy_list; |
| 220 |
} |
| 221 |
dummies_and_input[RUNLOOP] = arg_value_list; |
| 222 |
|
| 223 |
function testfunc() { |
| 224 |
|
| 225 |
mapfunc(dummies_and_input); |
| 226 |
return dummies_and_input[RUNLOOP]; |
| 227 |
} |
| 228 |
testfunc.name = funcname + "(" + args + ")"; |
| 229 |
testfunc.expected = expected; |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
test(testfunc); |
| 242 |
} |
| 243 |
|
| 244 |
testmath("Math.abs", "void 0", Number.NaN) |
| 245 |
testmath("Math.abs", "null", 0) |
| 246 |
testmath("Math.abs", "true", 1) |
| 247 |
testmath("Math.abs", "false", 0) |
| 248 |
testmath("Math.abs", "\"a string primitive\"", Number.NaN) |
| 249 |
testmath("Math.abs", "new String( 'a String object' )", Number.NaN) |
| 250 |
testmath("Math.abs", "Number.NaN", Number.NaN) |
| 251 |
testmath("Math.abs", "0", 0) |
| 252 |
testmath("Math.abs", "-0", 0) |
| 253 |
testmath("Infinity/Math.abs", "-0", Infinity) |
| 254 |
testmath("Math.abs", "Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 255 |
testmath("Math.abs", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 256 |
testmath("Math.abs", "- Number.MAX_VALUE", Number.MAX_VALUE) |
| 257 |
testmath("Math.abs", "-Number.MIN_VALUE", Number.MIN_VALUE) |
| 258 |
testmath("Math.abs", "Number.MAX_VALUE", Number.MAX_VALUE) |
| 259 |
testmath("Math.abs", "Number.MIN_VALUE", Number.MIN_VALUE) |
| 260 |
testmath("Math.abs", "-1", 1) |
| 261 |
testmath("Math.abs", "new Number(-1)", 1) |
| 262 |
testmath("Math.abs", "1", 1) |
| 263 |
testmath("Math.abs", "Math.PI", Math.PI) |
| 264 |
testmath("Math.abs", "-Math.PI", Math.PI) |
| 265 |
testmath("Math.abs", "-1/100000000", 1/100000000) |
| 266 |
testmath("Math.abs", "-Math.pow(2,32)", Math.pow(2,32)) |
| 267 |
testmath("Math.abs", "Math.pow(2,32)", Math.pow(2,32)) |
| 268 |
testmath("Math.abs", "-0xfff", 4095) |
| 269 |
testmath("Math.abs", "-0777", 511) |
| 270 |
testmath("Math.abs", "'-1e-1'", 0.1) |
| 271 |
testmath("Math.abs", "'0xff'", 255) |
| 272 |
testmath("Math.abs", "'077'", 77) |
| 273 |
testmath("Math.abs", "'Infinity'", Infinity) |
| 274 |
testmath("Math.abs", "'-Infinity'", Infinity) |
| 275 |
|
| 276 |
testmath("Math.acos", "void 0", Number.NaN) |
| 277 |
testmath("Math.acos", "null", Math.PI/2) |
| 278 |
testmath("Math.acos", "Number.NaN", Number.NaN) |
| 279 |
testmath("Math.acos", "\"a string\"", Number.NaN) |
| 280 |
testmath("Math.acos", "'0'", Math.PI/2) |
| 281 |
testmath("Math.acos", "'1'", 0) |
| 282 |
testmath("Math.acos", "'-1'", Math.PI) |
| 283 |
testmath("Math.acos", "1.00000001", Number.NaN) |
| 284 |
testmath("Math.acos", "-1.00000001", Number.NaN) |
| 285 |
testmath("Math.acos", "1", 0) |
| 286 |
testmath("Math.acos", "-1", Math.PI) |
| 287 |
testmath("Math.acos", "0", Math.PI/2) |
| 288 |
testmath("Math.acos", "-0", Math.PI/2) |
| 289 |
testmath("Math.acos", "Math.SQRT1_2", Math.PI/4) |
| 290 |
testmath("Math.acos", "-Math.SQRT1_2", Math.PI/4*3) |
| 291 |
testmath("Math.acos", "0.9999619230642", Math.PI/360) |
| 292 |
testmath("Math.acos", "-3.0", Number.NaN) |
| 293 |
|
| 294 |
testmath("Math.asin", "void 0", Number.NaN) |
| 295 |
testmath("Math.asin", "null", 0) |
| 296 |
testmath("Math.asin", "Number.NaN", Number.NaN) |
| 297 |
testmath("Math.asin", "\"string\"", Number.NaN) |
| 298 |
testmath("Math.asin", "\"0\"", 0) |
| 299 |
testmath("Math.asin", "\"1\"", Math.PI/2) |
| 300 |
testmath("Math.asin", "\"-1\"", -Math.PI/2) |
| 301 |
testmath("Math.asin", "Math.SQRT1_2+''", Math.PI/4) |
| 302 |
testmath("Math.asin", "-Math.SQRT1_2+''", -Math.PI/4) |
| 303 |
testmath("Math.asin", "1.000001", Number.NaN) |
| 304 |
testmath("Math.asin", "-1.000001", Number.NaN) |
| 305 |
testmath("Math.asin", "0", 0) |
| 306 |
testmath("Math.asin", "-0", -0) |
| 307 |
testmath("Infinity/Math.asin", "-0", -Infinity) |
| 308 |
testmath("Math.asin", "1", Math.PI/2) |
| 309 |
testmath("Math.asin", "-1", -Math.PI/2) |
| 310 |
testmath("Math.asin", "Math.SQRT1_2", Math.PI/4) |
| 311 |
testmath("Math.asin", "-Math.SQRT1_2", -Math.PI/4) |
| 312 |
|
| 313 |
testmath("Math.atan", "void 0", Number.NaN) |
| 314 |
testmath("Math.atan", "null", 0) |
| 315 |
testmath("Math.atan", "Number.NaN", Number.NaN) |
| 316 |
testmath("Math.atan", "\"a string\"", Number.NaN) |
| 317 |
testmath("Math.atan", "'0'", 0) |
| 318 |
testmath("Math.atan", "'1'", Math.PI/4) |
| 319 |
testmath("Math.atan", "'-1'", -Math.PI/4) |
| 320 |
testmath("Math.atan", "'Infinity'", Math.PI/2) |
| 321 |
testmath("Math.atan", "'-Infinity'", -Math.PI/2) |
| 322 |
testmath("Math.atan", "0", 0) |
| 323 |
testmath("Math.atan", "-0", -0) |
| 324 |
testmath("Infinity/Math.atan", "-0", -Infinity) |
| 325 |
testmath("Math.atan", "Number.POSITIVE_INFINITY", Math.PI/2) |
| 326 |
testmath("Math.atan", "Number.NEGATIVE_INFINITY", -Math.PI/2) |
| 327 |
testmath("Math.atan", "1", Math.PI/4) |
| 328 |
testmath("Math.atan", "-1", -Math.PI/4) |
| 329 |
|
| 330 |
testmath("Math.atan2", "Number.NaN,0", Number.NaN) |
| 331 |
testmath("Math.atan2", "null, null", 0) |
| 332 |
testmath("Math.atan2", "void 0, void 0", Number.NaN) |
| 333 |
testmath("Math.atan2", "0,Number.NaN", Number.NaN) |
| 334 |
testmath("Math.atan2", "1,0", Math.PI/2) |
| 335 |
testmath("Math.atan2", "1,-0", Math.PI/2) |
| 336 |
testmath("Math.atan2", "0,0.001", 0) |
| 337 |
testmath("Math.atan2", "0,0", 0) |
| 338 |
testmath("Math.atan2", "0,-0", Math.PI) |
| 339 |
testmath("Math.atan2", "0, -1", Math.PI) |
| 340 |
testmath("Math.atan2", "-0, 1", -0) |
| 341 |
testmath("Infinity/Math.atan2", "-0,1", -Infinity) |
| 342 |
testmath("Math.atan2", "-0,0", -0) |
| 343 |
testmath("Math.atan2", "-0, -0", -Math.PI) |
| 344 |
testmath("Math.atan2", "-0, -1", -Math.PI) |
| 345 |
testmath("Math.atan2", "-1, 0", -Math.PI/2) |
| 346 |
testmath("Math.atan2", "-1, -0", -Math.PI/2) |
| 347 |
testmath("Math.atan2", "1, Number.POSITIVE_INFINITY", 0) |
| 348 |
testmath("Math.atan2", "1, Number.NEGATIVE_INFINITY", Math.PI) |
| 349 |
testmath("Math.atan2", "-1,Number.POSITIVE_INFINITY", -0) |
| 350 |
testmath("Infinity/Math.atan2", "-1,Infinity", -Infinity) |
| 351 |
testmath("Math.atan2", "-1,Number.NEGATIVE_INFINITY", -Math.PI) |
| 352 |
testmath("Math.atan2", "Number.POSITIVE_INFINITY, 0", Math.PI/2) |
| 353 |
testmath("Math.atan2", "Number.POSITIVE_INFINITY, 1", Math.PI/2) |
| 354 |
testmath("Math.atan2", "Number.POSITIVE_INFINITY,-1", Math.PI/2) |
| 355 |
testmath("Math.atan2", "Number.POSITIVE_INFINITY,-0", Math.PI/2) |
| 356 |
testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 0", -Math.PI/2) |
| 357 |
testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-0", -Math.PI/2) |
| 358 |
testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 1", -Math.PI/2) |
| 359 |
testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-1", -Math.PI/2) |
| 360 |
testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY", Math.PI/4) |
| 361 |
testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY", 3*Math.PI/4) |
| 362 |
testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", -Math.PI/4) |
| 363 |
testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", -3*Math.PI/4) |
| 364 |
testmath("Math.atan2", "-1, 1", -Math.PI/4) |
| 365 |
|
| 366 |
testmath("Math.ceil", "Number.NaN", Number.NaN) |
| 367 |
testmath("Math.ceil", "null", 0) |
| 368 |
testmath("Math.ceil", "void 0", Number.NaN) |
| 369 |
testmath("Math.ceil", "'0'", 0) |
| 370 |
testmath("Math.ceil", "'-0'", -0) |
| 371 |
testmath("Infinity/Math.ceil", "'0'", Infinity) |
| 372 |
testmath("Infinity/Math.ceil", "'-0'", -Infinity) |
| 373 |
testmath("Math.ceil", "0", 0) |
| 374 |
testmath("Math.ceil", "-0", -0) |
| 375 |
testmath("Infinity/Math.ceil", "0", Infinity) |
| 376 |
testmath("Infinity/Math.ceil", "-0", -Infinity) |
| 377 |
testmath("Math.ceil", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 378 |
testmath("Math.ceil", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
| 379 |
testmath("Math.ceil", "-Number.MIN_VALUE", -0) |
| 380 |
testmath("Infinity/Math.ceil", "-Number.MIN_VALUE", -Infinity) |
| 381 |
testmath("Math.ceil", "1", 1) |
| 382 |
testmath("Math.ceil", "-1", -1) |
| 383 |
testmath("Math.ceil", "-0.9", -0) |
| 384 |
testmath("Infinity/Math.ceil", "-0.9", -Infinity) |
| 385 |
testmath("Math.ceil", "0.9", 1) |
| 386 |
testmath("Math.ceil", "-1.1", -1) |
| 387 |
testmath("Math.ceil", "1.1", 2) |
| 388 |
testmath("Math.ceil", "Number.POSITIVE_INFINITY", -Math.floor(-Infinity)) |
| 389 |
testmath("Math.ceil", "Number.NEGATIVE_INFINITY", -Math.floor(Infinity)) |
| 390 |
testmath("Math.ceil", "-Number.MIN_VALUE", -Math.floor(Number.MIN_VALUE)) |
| 391 |
testmath("Math.ceil", "1", -Math.floor(-1)) |
| 392 |
testmath("Math.ceil", "-1", -Math.floor(1)) |
| 393 |
testmath("Math.ceil", "-0.9", -Math.floor(0.9)) |
| 394 |
testmath("Math.ceil", "0.9", -Math.floor(-0.9)) |
| 395 |
testmath("Math.ceil", "-1.1", -Math.floor(1.1)) |
| 396 |
testmath("Math.ceil", "1.1", -Math.floor(-1.1)) |
| 397 |
|
| 398 |
testmath("Math.cos", "void 0", Number.NaN) |
| 399 |
testmath("Math.cos", "false", 1) |
| 400 |
testmath("Math.cos", "null", 1) |
| 401 |
testmath("Math.cos", "'0'", 1) |
| 402 |
testmath("Math.cos", "\"Infinity\"", Number.NaN) |
| 403 |
testmath("Math.cos", "'3.14159265359'", -1) |
| 404 |
testmath("Math.cos", "Number.NaN", Number.NaN) |
| 405 |
testmath("Math.cos", "0", 1) |
| 406 |
testmath("Math.cos", "-0", 1) |
| 407 |
testmath("Math.cos", "Number.POSITIVE_INFINITY", Number.NaN) |
| 408 |
testmath("Math.cos", "Number.NEGATIVE_INFINITY", Number.NaN) |
| 409 |
testmath("Math.cos", "0.7853981633974", 0.7071067811865) |
| 410 |
testmath("Math.cos", "1.570796326795", 0) |
| 411 |
testmath("Math.cos", "2.356194490192", -0.7071067811865) |
| 412 |
testmath("Math.cos", "3.14159265359", -1) |
| 413 |
testmath("Math.cos", "3.926990816987", -0.7071067811865) |
| 414 |
testmath("Math.cos", "4.712388980385", 0) |
| 415 |
testmath("Math.cos", "5.497787143782", 0.7071067811865) |
| 416 |
testmath("Math.cos", "Math.PI*2", 1) |
| 417 |
testmath("Math.cos", "Math.PI/4", Math.SQRT2/2) |
| 418 |
testmath("Math.cos", "Math.PI/2", 0) |
| 419 |
testmath("Math.cos", "3*Math.PI/4", -Math.SQRT2/2) |
| 420 |
testmath("Math.cos", "Math.PI", -1) |
| 421 |
testmath("Math.cos", "5*Math.PI/4", -Math.SQRT2/2) |
| 422 |
testmath("Math.cos", "3*Math.PI/2", 0) |
| 423 |
testmath("Math.cos", "7*Math.PI/4", Math.SQRT2/2) |
| 424 |
testmath("Math.cos", "2*Math.PI", 1) |
| 425 |
testmath("Math.cos", "-0.7853981633974", 0.7071067811865) |
| 426 |
testmath("Math.cos", "-1.570796326795", 0) |
| 427 |
testmath("Math.cos", "2.3561944901920", -.7071067811865) |
| 428 |
testmath("Math.cos", "3.14159265359", -1) |
| 429 |
testmath("Math.cos", "3.926990816987", -0.7071067811865) |
| 430 |
testmath("Math.cos", "4.712388980385", 0) |
| 431 |
testmath("Math.cos", "5.497787143782", 0.7071067811865) |
| 432 |
testmath("Math.cos", "6.28318530718", 1) |
| 433 |
testmath("Math.cos", "-Math.PI/4", Math.SQRT2/2) |
| 434 |
testmath("Math.cos", "-Math.PI/2", 0) |
| 435 |
testmath("Math.cos", "-3*Math.PI/4", -Math.SQRT2/2) |
| 436 |
testmath("Math.cos", "-Math.PI", -1) |
| 437 |
testmath("Math.cos", "-5*Math.PI/4", -Math.SQRT2/2) |
| 438 |
testmath("Math.cos", "-3*Math.PI/2", 0) |
| 439 |
testmath("Math.cos", "-7*Math.PI/4", Math.SQRT2/2) |
| 440 |
testmath("Math.cos", "-Math.PI*2", 1) |
| 441 |
|
| 442 |
testmath("Math.exp", "null", 1) |
| 443 |
testmath("Math.exp", "void 0", Number.NaN) |
| 444 |
testmath("Math.exp", "1", Math.E) |
| 445 |
testmath("Math.exp", "true", Math.E) |
| 446 |
testmath("Math.exp", "false", 1) |
| 447 |
testmath("Math.exp", "'1'", Math.E) |
| 448 |
testmath("Math.exp", "'0'", 1) |
| 449 |
testmath("Math.exp", "Number.NaN", Number.NaN) |
| 450 |
testmath("Math.exp", "0", 1) |
| 451 |
testmath("Math.exp", "-0", 1) |
| 452 |
testmath("Math.exp", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 453 |
testmath("Math.exp", "Number.NEGATIVE_INFINITY", 0) |
| 454 |
|
| 455 |
testmath("Math.floor", "void 0", Number.NaN) |
| 456 |
testmath("Math.floor", "null", 0) |
| 457 |
testmath("Math.floor", "true", 1) |
| 458 |
testmath("Math.floor", "false", 0) |
| 459 |
testmath("Math.floor", "\"1.1\"", 1) |
| 460 |
testmath("Math.floor", "\"-1.1\"", -2) |
| 461 |
testmath("Math.floor", "\"0.1\"", 0) |
| 462 |
testmath("Math.floor", "\"-0.1\"", -1) |
| 463 |
testmath("Math.floor", "Number.NaN", Number.NaN) |
| 464 |
testmath("Math.floor(Number.NaN) == -Math.ceil", "-Number.NaN", false) |
| 465 |
testmath("Math.floor", "0", 0) |
| 466 |
testmath("Math.floor(0) == -Math.ceil", "-0", true) |
| 467 |
testmath("Math.floor", "-0", -0) |
| 468 |
testmath("Infinity/Math.floor", "-0", -Infinity) |
| 469 |
testmath("Math.floor(-0)== -Math.ceil", "0", true) |
| 470 |
testmath("Math.floor", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 471 |
testmath("Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil", "Number.NEGATIVE_INFINITY", true) |
| 472 |
testmath("Math.floor", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
| 473 |
testmath("Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil", "Number.POSITIVE_INFINITY", true) |
| 474 |
testmath("Math.floor", "0.0000001", 0) |
| 475 |
testmath("Math.floor(0.0000001)==-Math.ceil", "-0.0000001", true) |
| 476 |
testmath("Math.floor", "-0.0000001", -1) |
| 477 |
testmath("Math.floor(-0.0000001)==-Math.ceil", "0.0000001", true) |
| 478 |
|
| 479 |
testmath("Math.log", "void 0", Number.NaN) |
| 480 |
testmath("Math.log", "null", Number.NEGATIVE_INFINITY) |
| 481 |
testmath("Math.log", "true", 0) |
| 482 |
testmath("Math.log", "false", -Infinity) |
| 483 |
testmath("Math.log", "'0'", -Infinity) |
| 484 |
testmath("Math.log", "'1'", 0) |
| 485 |
testmath("Math.log", "\"Infinity\"", Infinity) |
| 486 |
testmath("Math.log", "Number.NaN", Number.NaN) |
| 487 |
testmath("Math.log", "-0.000001", Number.NaN) |
| 488 |
testmath("Math.log", "-1", Number.NaN) |
| 489 |
testmath("Math.log", "0", Number.NEGATIVE_INFINITY) |
| 490 |
testmath("Math.log", "-0", Number.NEGATIVE_INFINITY) |
| 491 |
testmath("Math.log", "1", 0) |
| 492 |
testmath("Math.log", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 493 |
testmath("Math.log", "Number.NEGATIVE_INFINITY", Number.NaN) |
| 494 |
|
| 495 |
testmath("Math.max", "void 0, 1", Number.NaN) |
| 496 |
testmath("Math.max", "void 0, void 0", Number.NaN) |
| 497 |
testmath("Math.max", "null, 1", 1) |
| 498 |
testmath("Math.max", "-1, null", 0) |
| 499 |
testmath("Math.max", "true,false", 1) |
| 500 |
testmath("Math.max", "\"-99\",\"99\"", 99) |
| 501 |
testmath("Math.max", "Number.NaN,Number.POSITIVE_INFINITY", Number.NaN) |
| 502 |
testmath("Math.max", "Number.NaN, 0", Number.NaN) |
| 503 |
testmath("Math.max", "\"a string\", 0", Number.NaN) |
| 504 |
testmath("Math.max", "Number.NaN,1", Number.NaN) |
| 505 |
testmath("Math.max", "\"a string\", Number.POSITIVE_INFINITY", Number.NaN) |
| 506 |
testmath("Math.max", "Number.POSITIVE_INFINITY, Number.NaN", Number.NaN) |
| 507 |
testmath("Math.max", "Number.NaN, Number.NaN", Number.NaN) |
| 508 |
testmath("Math.max", "0,Number.NaN", Number.NaN) |
| 509 |
testmath("Math.max", "1, Number.NaN", Number.NaN) |
| 510 |
testmath("Math.max", "0,0", 0) |
| 511 |
testmath("Math.max", "0,-0", 0) |
| 512 |
testmath("Math.max", "-0,0", 0) |
| 513 |
testmath("Math.max", "-0,-0", -0) |
| 514 |
testmath("Infinity/Math.max", "-0,-0", -Infinity) |
| 515 |
testmath("Math.max", "Number.POSITIVE_INFINITY, Number.MAX_VALUE", Number.POSITIVE_INFINITY) |
| 516 |
testmath("Math.max", "Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 517 |
testmath("Math.max", "Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
| 518 |
testmath("Math.max", "1,.99999999999999", 1) |
| 519 |
testmath("Math.max", "-1,-.99999999999999", -.99999999999999) |
| 520 |
|
| 521 |
testmath("Math.min", "void 0, 1", Number.NaN) |
| 522 |
testmath("Math.min", "void 0, void 0", Number.NaN) |
| 523 |
testmath("Math.min", "null, 1", 0) |
| 524 |
testmath("Math.min", "-1, null", -1) |
| 525 |
testmath("Math.min", "true,false", 0) |
| 526 |
testmath("Math.min", "\"-99\",\"99\"", -99) |
| 527 |
testmath("Math.min", "Number.NaN,0", Number.NaN) |
| 528 |
testmath("Math.min", "Number.NaN,1", Number.NaN) |
| 529 |
testmath("Math.min", "Number.NaN,-1", Number.NaN) |
| 530 |
testmath("Math.min", "0,Number.NaN", Number.NaN) |
| 531 |
testmath("Math.min", "1,Number.NaN", Number.NaN) |
| 532 |
testmath("Math.min", "-1,Number.NaN", Number.NaN) |
| 533 |
testmath("Math.min", "Number.NaN,Number.NaN", Number.NaN) |
| 534 |
testmath("Math.min", "1,1.0000000001", 1) |
| 535 |
testmath("Math.min", "1.0000000001,1", 1) |
| 536 |
testmath("Math.min", "0,0", 0) |
| 537 |
testmath("Math.min", "0,-0", -0) |
| 538 |
testmath("Math.min", "-0,-0", -0) |
| 539 |
testmath("Infinity/Math.min", "0,-0", -Infinity) |
| 540 |
testmath("Infinity/Math.min", "-0,-0", -Infinity) |
| 541 |
|
| 542 |
testmath("Math.pow", "null,null", 1) |
| 543 |
testmath("Math.pow", "void 0, void 0", Number.NaN) |
| 544 |
testmath("Math.pow", "true, false", 1) |
| 545 |
testmath("Math.pow", "false,true", 0) |
| 546 |
testmath("Math.pow", "'2','32'", 4294967296) |
| 547 |
testmath("Math.pow", "1,Number.NaN", Number.NaN) |
| 548 |
testmath("Math.pow", "0,Number.NaN", Number.NaN) |
| 549 |
testmath("Math.pow", "Number.NaN,0", 1) |
| 550 |
testmath("Math.pow", "Number.NaN,-0", 1) |
| 551 |
testmath("Math.pow", "Number.NaN, 1", Number.NaN) |
| 552 |
testmath("Math.pow", "Number.NaN, .5", Number.NaN) |
| 553 |
testmath("Math.pow", "1.00000001, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 554 |
testmath("Math.pow", "1.00000001, Number.NEGATIVE_INFINITY", 0) |
| 555 |
testmath("Math.pow", "-1.00000001,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 556 |
testmath("Math.pow", "-1.00000001,Number.NEGATIVE_INFINITY", 0) |
| 557 |
testmath("Math.pow", "1, Number.POSITIVE_INFINITY", Number.NaN) |
| 558 |
testmath("Math.pow", "1, Number.NEGATIVE_INFINITY", Number.NaN) |
| 559 |
testmath("Math.pow", "-1, Number.POSITIVE_INFINITY", Number.NaN) |
| 560 |
testmath("Math.pow", "-1, Number.NEGATIVE_INFINITY", Number.NaN) |
| 561 |
testmath("Math.pow", ".0000000009, Number.POSITIVE_INFINITY", 0) |
| 562 |
testmath("Math.pow", "-.0000000009, Number.POSITIVE_INFINITY", 0) |
| 563 |
testmath("Math.pow", "-.0000000009, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 564 |
testmath("Math.pow", "Number.POSITIVE_INFINITY,.00000000001", Number.POSITIVE_INFINITY) |
| 565 |
testmath("Math.pow", "Number.POSITIVE_INFINITY, 1", Number.POSITIVE_INFINITY) |
| 566 |
testmath("Math.pow", "Number.POSITIVE_INFINITY, -.00000000001", 0) |
| 567 |
testmath("Math.pow", "Number.POSITIVE_INFINITY, -1", 0) |
| 568 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, 1", Number.NEGATIVE_INFINITY) |
| 569 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, 333", Number.NEGATIVE_INFINITY) |
| 570 |
testmath("Math.pow", "Number.POSITIVE_INFINITY, 2", Number.POSITIVE_INFINITY) |
| 571 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, 666", Number.POSITIVE_INFINITY) |
| 572 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, 0.5", Number.POSITIVE_INFINITY) |
| 573 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 574 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, -1", -0) |
| 575 |
testmath("Infinity/Math.pow", "Number.NEGATIVE_INFINITY, -1", -Infinity) |
| 576 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, -3", -0) |
| 577 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, -2", 0) |
| 578 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY,-0.5", 0) |
| 579 |
testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", 0) |
| 580 |
testmath("Math.pow", "0,1", 0) |
| 581 |
testmath("Math.pow", "0,0", 1) |
| 582 |
testmath("Math.pow", "1,0", 1) |
| 583 |
testmath("Math.pow", "-1,0", 1) |
| 584 |
testmath("Math.pow", "0,0.5", 0) |
| 585 |
testmath("Math.pow", "0,1000", 0) |
| 586 |
testmath("Math.pow", "0, Number.POSITIVE_INFINITY", 0) |
| 587 |
testmath("Math.pow", "0, -1", Number.POSITIVE_INFINITY) |
| 588 |
testmath("Math.pow", "0, -0.5", Number.POSITIVE_INFINITY) |
| 589 |
testmath("Math.pow", "0, -1000", Number.POSITIVE_INFINITY) |
| 590 |
testmath("Math.pow", "0, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 591 |
testmath("Math.pow", "-0, 1", -0) |
| 592 |
testmath("Math.pow", "-0,3", -0) |
| 593 |
testmath("Infinity/Math.pow", "-0, 1", -Infinity) |
| 594 |
testmath("Infinity/Math.pow", "-0,3", -Infinity) |
| 595 |
testmath("Math.pow", "-0,2", 0) |
| 596 |
testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0) |
| 597 |
testmath("Math.pow", "-0, -1", Number.NEGATIVE_INFINITY) |
| 598 |
testmath("Math.pow", "-0, -10001", Number.NEGATIVE_INFINITY) |
| 599 |
testmath("Math.pow", "-0, -2", Number.POSITIVE_INFINITY) |
| 600 |
testmath("Math.pow", "-0, 0.5", 0) |
| 601 |
testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0) |
| 602 |
testmath("Math.pow", "-1, 0.5", Number.NaN) |
| 603 |
testmath("Math.pow", "-1, Number.NaN", Number.NaN) |
| 604 |
testmath("Math.pow", "-1, -0.5", Number.NaN) |
| 605 |
|
| 606 |
testmath("Math.round", "0", 0) |
| 607 |
testmath("Math.round", "void 0", Number.NaN) |
| 608 |
testmath("Math.round", "true", 1) |
| 609 |
testmath("Math.round", "false", 0) |
| 610 |
testmath("Math.round", "'.99999'", 1) |
| 611 |
testmath("Math.round", "'12345e-2'", 123) |
| 612 |
testmath("Math.round", "Number.NaN", Number.NaN) |
| 613 |
testmath("Math.round", "0", 0) |
| 614 |
testmath("Math.round", "-0", -0) |
| 615 |
testmath("Infinity/Math.round", "-0", -Infinity) |
| 616 |
testmath("Math.round", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 617 |
testmath("Math.round", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
| 618 |
testmath("Math.round", "0.49", 0) |
| 619 |
testmath("Math.round", "0.5", 1) |
| 620 |
testmath("Math.round", "0.51", 1) |
| 621 |
testmath("Math.round", "-0.49", -0) |
| 622 |
testmath("Math.round", "-0.5", -0) |
| 623 |
testmath("Infinity/Math.round", "-0.49", -Infinity) |
| 624 |
testmath("Infinity/Math.round", "-0.5", -Infinity) |
| 625 |
testmath("Math.round", "-0.51", -1) |
| 626 |
testmath("Math.round", "3.5", 4) |
| 627 |
testmath("Math.round", "-3", -3) |
| 628 |
|
| 629 |
testmath("Math.sin", "null", 0) |
| 630 |
testmath("Math.sin", "void 0", Number.NaN) |
| 631 |
testmath("Math.sin", "false", 0) |
| 632 |
testmath("Math.sin", "'2.356194490192'", 0.7071067811865) |
| 633 |
testmath("Math.sin", "Number.NaN", Number.NaN) |
| 634 |
testmath("Math.sin", "0", 0) |
| 635 |
testmath("Math.sin", "-0", -0) |
| 636 |
testmath("Math.sin", "Number.POSITIVE_INFINITY", Number.NaN) |
| 637 |
testmath("Math.sin", "Number.NEGATIVE_INFINITY", Number.NaN) |
| 638 |
testmath("Math.sin", "0.7853981633974", 0.7071067811865) |
| 639 |
testmath("Math.sin", "1.570796326795", 1) |
| 640 |
testmath("Math.sin", "2.356194490192", 0.7071067811865) |
| 641 |
testmath("Math.sin", "3.14159265359", 0) |
| 642 |
|
| 643 |
testmath("Math.sqrt", "void 0", Number.NaN) |
| 644 |
testmath("Math.sqrt", "null", 0) |
| 645 |
testmath("Math.sqrt", "1", 1) |
| 646 |
testmath("Math.sqrt", "false", 0) |
| 647 |
testmath("Math.sqrt", "'225'", 15) |
| 648 |
testmath("Math.sqrt", "Number.NaN", Number.NaN) |
| 649 |
testmath("Math.sqrt", "Number.NEGATIVE_INFINITY", Number.NaN) |
| 650 |
testmath("Math.sqrt", "-1", Number.NaN) |
| 651 |
testmath("Math.sqrt", "-0.5", Number.NaN) |
| 652 |
testmath("Math.sqrt", "0", 0) |
| 653 |
testmath("Math.sqrt", "-0", -0) |
| 654 |
testmath("Infinity/Math.sqrt", "-0", -Infinity) |
| 655 |
testmath("Math.sqrt", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
| 656 |
testmath("Math.sqrt", "1", 1) |
| 657 |
testmath("Math.sqrt", "2", Math.SQRT2) |
| 658 |
testmath("Math.sqrt", "0.5", Math.SQRT1_2) |
| 659 |
testmath("Math.sqrt", "4", 2) |
| 660 |
testmath("Math.sqrt", "9", 3) |
| 661 |
testmath("Math.sqrt", "16", 4) |
| 662 |
testmath("Math.sqrt", "25", 5) |
| 663 |
testmath("Math.sqrt", "36", 6) |
| 664 |
testmath("Math.sqrt", "49", 7) |
| 665 |
testmath("Math.sqrt", "64", 8) |
| 666 |
testmath("Math.sqrt", "256", 16) |
| 667 |
testmath("Math.sqrt", "10000", 100) |
| 668 |
testmath("Math.sqrt", "65536", 256) |
| 669 |
testmath("Math.sqrt", "0.09", 0.3) |
| 670 |
testmath("Math.sqrt", "0.01", 0.1) |
| 671 |
testmath("Math.sqrt", "0.00000001", 0.0001) |
| 672 |
|
| 673 |
testmath("Math.tan", "void 0", Number.NaN) |
| 674 |
testmath("Math.tan", "null", 0) |
| 675 |
testmath("Math.tan", "false", 0) |
| 676 |
testmath("Math.tan", "Number.NaN", Number.NaN) |
| 677 |
testmath("Math.tan", "0", 0) |
| 678 |
testmath("Math.tan", "-0", -0) |
| 679 |
testmath("Math.tan", "Number.POSITIVE_INFINITY", Number.NaN) |
| 680 |
testmath("Math.tan", "Number.NEGATIVE_INFINITY", Number.NaN) |
| 681 |
testmath("Math.tan", "Math.PI/4", 1) |
| 682 |
testmath("Math.tan", "3*Math.PI/4", -1) |
| 683 |
testmath("Math.tan", "Math.PI", -0) |
| 684 |
testmath("Math.tan", "5*Math.PI/4", 1) |
| 685 |
testmath("Math.tan", "7*Math.PI/4", -1) |
| 686 |
testmath("Infinity/Math.tan", "-0", -Infinity) |
| 687 |
|
| 688 |
jit(false); |
| 689 |
|
| 690 |
|
| 691 |
if (0) { |
| 692 |
print("\npassed:", passes.length && passes.join(",")); |
| 693 |
print("\nFAILED:", fails.length && fails.join(",")); |
| 694 |
} |