js/src/tests/js1_8_1/jit/math-jit-tests.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_8_1/jit/math-jit-tests.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,689 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +//-----------------------------------------------------------------------------
    1.10 +var BUGNUMBER = 'none';
    1.11 +var summary = 'trace-capability math mini-testsuite';
    1.12 +
    1.13 +printBugNumber(BUGNUMBER);
    1.14 +printStatus (summary);
    1.15 +
    1.16 +jit(true);
    1.17 +
    1.18 +/**
    1.19 + * A number of the tests in this file depend on the setting of
    1.20 + * HOTLOOP.  Define some constants up front, so they're easy to grep
    1.21 + * for.
    1.22 + */
    1.23 +// The HOTLOOP constant we depend on; only readable from our stats
    1.24 +// object in debug builds.
    1.25 +const haveTracemonkey = !!(this.tracemonkey)
    1.26 +const HOTLOOP = haveTracemonkey ? tracemonkey.HOTLOOP : 2;
    1.27 +
    1.28 +var testName = null;
    1.29 +if ("arguments" in this && arguments.length > 0)
    1.30 +  testName = arguments[0];
    1.31 +var fails = [], passes=[];
    1.32 +
    1.33 +function jitstatHandler(f)
    1.34 +{
    1.35 +  if (!haveTracemonkey) 
    1.36 +    return;
    1.37 +
    1.38 +  // XXXbz this is a nasty hack, but I can't figure out a way to
    1.39 +  // just use jitstats.tbl here
    1.40 +  f("recorderStarted");
    1.41 +  f("recorderAborted");
    1.42 +  f("traceCompleted");
    1.43 +  f("sideExitIntoInterpreter");
    1.44 +  f("typeMapMismatchAtEntry");
    1.45 +  f("returnToDifferentLoopHeader");
    1.46 +  f("traceTriggered");
    1.47 +  f("globalShapeMismatchAtEntry");
    1.48 +  f("treesTrashed");
    1.49 +  f("slotPromoted");
    1.50 +  f("unstableLoopVariable");
    1.51 +  f("noCompatInnerTrees");
    1.52 +  f("breakLoopExits");
    1.53 +  f("returnLoopExits");
    1.54 +}
    1.55 +
    1.56 +function test(f)
    1.57 +{
    1.58 +  if (!testName || testName == f.name) {
    1.59 +    // Collect our jit stats
    1.60 +    var localJITstats = {};
    1.61 +    jitstatHandler(function(prop, local, global) {
    1.62 +        localJITstats[prop] = tracemonkey[prop];
    1.63 +      });
    1.64 +    check(f.name, f(), f.expected, localJITstats, f.jitstats);
    1.65 +  }
    1.66 +}
    1.67 +
    1.68 +function map_test(t, cases)
    1.69 +{
    1.70 +  for (var i = 0; i < cases.length; i++) {
    1.71 +    function c() { return t(cases[i].input); }
    1.72 +    c.expected = cases[i].expected;
    1.73 +    c.name = t.name + "(" + uneval(cases[i].input) + ")";
    1.74 +    test(c);
    1.75 +  }
    1.76 +}
    1.77 +
    1.78 +// Use this function to compare expected and actual test results.
    1.79 +// Types must match.
    1.80 +// For numbers, treat NaN as matching NaN, distinguish 0 and -0, and
    1.81 +// tolerate a certain degree of error for other values.
    1.82 +//
    1.83 +// These are the same criteria used by the tests in js/tests, except that
    1.84 +// we distinguish 0 and -0.
    1.85 +function close_enough(expected, actual)
    1.86 +{
    1.87 +  if (typeof expected != typeof actual)
    1.88 +    return false;
    1.89 +  if (typeof expected != 'number')
    1.90 +    return actual == expected;
    1.91 +
    1.92 +  // Distinguish NaN from other values.  Using x != x comparisons here
    1.93 +  // works even if tests redefine isNaN.
    1.94 +  if (actual != actual)
    1.95 +    return expected != expected
    1.96 +      if (expected != expected)
    1.97 +        return false;
    1.98 +
    1.99 +  // Tolerate a certain degree of error.
   1.100 +  if (actual != expected)
   1.101 +    return Math.abs(actual - expected) <= 1E-10;
   1.102 +
   1.103 +  // Distinguish 0 and -0.
   1.104 +  if (actual == 0)
   1.105 +    return (1 / actual > 0) == (1 / expected > 0);
   1.106 +
   1.107 +  return true;
   1.108 +}
   1.109 +
   1.110 +function check(desc, actual, expected, oldJITstats, expectedJITstats)
   1.111 +{
   1.112 +  var pass = false;
   1.113 +  if (close_enough(expected, actual)) {
   1.114 +    pass = true;
   1.115 +    jitstatHandler(function(prop) {
   1.116 +        if (expectedJITstats && prop in expectedJITstats &&
   1.117 +            expectedJITstats[prop] !=
   1.118 +            tracemonkey[prop] - oldJITstats[prop]) {
   1.119 +          pass = false;
   1.120 +        }
   1.121 +      });
   1.122 +    if (pass) {
   1.123 +      reportCompare(expected, actual, desc);
   1.124 +      passes.push(desc);
   1.125 +      return print(desc, ": passed");
   1.126 +    }
   1.127 +  }
   1.128 +
   1.129 +  if (expected instanceof RegExp) {
   1.130 +    pass = reportMatch(expected, actual + '', desc);
   1.131 +    if (pass) {
   1.132 +      jitstatHandler(function(prop) {
   1.133 +          if (expectedJITstats && prop in expectedJITstats &&
   1.134 +              expectedJITstats[prop] !=
   1.135 +              tracemonkey[prop] - oldJITstats[prop]) {
   1.136 +            pass = false;
   1.137 +          }
   1.138 +        });
   1.139 +    }
   1.140 +    if (pass) {
   1.141 +      passes.push(desc);
   1.142 +      return print(desc, ": passed");
   1.143 +    }
   1.144 +  }
   1.145 +
   1.146 +  reportCompare(expected, actual, desc);
   1.147 +
   1.148 +  fails.push(desc);
   1.149 +  var expectedStats = "";
   1.150 +  if (expectedJITstats) {
   1.151 +    jitstatHandler(function(prop) {
   1.152 +        if (prop in expectedJITstats) {
   1.153 +          if (expectedStats)
   1.154 +            expectedStats += " ";
   1.155 +          expectedStats +=
   1.156 +            prop + ": " + expectedJITstats[prop];
   1.157 +        }
   1.158 +      });
   1.159 +  }
   1.160 +  var actualStats = "";
   1.161 +  if (expectedJITstats) {
   1.162 +    jitstatHandler(function(prop) {
   1.163 +        if (prop in expectedJITstats) {
   1.164 +          if (actualStats)
   1.165 +            actualStats += " ";
   1.166 +          actualStats += prop + ": " + (tracemonkey[prop]-oldJITstats[prop]);
   1.167 +        }
   1.168 +      });
   1.169 +  }
   1.170 +  print(desc, ": FAILED: expected", typeof(expected), 
   1.171 +        "(", uneval(expected), ")",
   1.172 +        (expectedStats ? " [" + expectedStats + "] " : ""),
   1.173 +        "!= actual",
   1.174 +        typeof(actual), "(", uneval(actual), ")",
   1.175 +        (actualStats ? " [" + actualStats + "] " : ""));
   1.176 +}
   1.177 +
   1.178 +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
   1.179 +
   1.180 +// Apply FUNCNAME to ARGS, and check against EXPECTED.
   1.181 +// Expect a loop containing such a call to be traced.
   1.182 +// FUNCNAME and ARGS are both strings.
   1.183 +// ARGS has the form of an argument list: a comma-separated list of expressions.
   1.184 +// Certain Tracemonkey limitations require us to pass FUNCNAME as a string.
   1.185 +// Passing ARGS as a string allows us to assign better test names:
   1.186 +// expressions like Math.PI/4 haven't been evaluated to big hairy numbers.
   1.187 +function testmath(funcname, args, expected) {
   1.188 +    var i, j;
   1.189 +
   1.190 +    var arg_value_list = eval("[" + args + "]");
   1.191 +    var arity = arg_value_list.length;
   1.192 +
   1.193 +    // Build the string "a[i][0],...,a[i][ARITY-1]".
   1.194 +    var actuals = []
   1.195 +    for (i = 0; i < arity; i++)
   1.196 +        actuals.push("a[i][" + i + "]");
   1.197 +    actuals = actuals.join(",");
   1.198 +
   1.199 +    // Create a function that maps FUNCNAME across an array of input values.
   1.200 +    // Unless we eval here, the call to funcname won't get traced.
   1.201 +    // FUNCNAME="Infinity/Math.abs" and cases like that happen to
   1.202 +    // parse, too, in a twisted way.
   1.203 +    var mapfunc = eval("(function(a) {\n"
   1.204 +                       + "   for (var i = 0; i < a.length; i++)\n"
   1.205 +                       + "       a[i] = " + funcname + "(" + actuals +");\n"
   1.206 +                       + " })\n");
   1.207 +
   1.208 +    // To prevent the compiler from doing constant folding, produce an
   1.209 +    // array to pass to mapfunc that contains enough dummy
   1.210 +    // values at the front to get the loop body jitted, and then our
   1.211 +    // actual test value.
   1.212 +    var dummies_and_input = [];
   1.213 +    for (i = 0; i < RUNLOOP; i++) {
   1.214 +        var dummy_list = [];
   1.215 +        for (j = 0; j < arity; j++)
   1.216 +            dummy_list[j] = .0078125 * ((i + j) % 128);
   1.217 +        dummies_and_input[i] = dummy_list;
   1.218 +    }
   1.219 +    dummies_and_input[RUNLOOP] = arg_value_list;
   1.220 +
   1.221 +    function testfunc() {
   1.222 +        // Map the function across the dummy values and the test input.
   1.223 +        mapfunc(dummies_and_input);
   1.224 +        return dummies_and_input[RUNLOOP];
   1.225 +    }
   1.226 +    testfunc.name = funcname + "(" + args + ")";
   1.227 +    testfunc.expected = expected;
   1.228 +
   1.229 +    // Disable jitstats check. This never worked right. The actual part of the
   1.230 +    // loop we cared about was never traced. We traced the filler parts early
   1.231 +    // and then took a mismatch side exit on every subequent array read with
   1.232 +    // a different type (gal, discovered when fixing bug 479110).
   1.233 +    // testfunc.jitstats = {
   1.234 +    //   recorderStarted: 1,
   1.235 +    //   recorderAborted: 0,
   1.236 +    //   traceTriggered: 1
   1.237 +    // };
   1.238 +
   1.239 +    test(testfunc);
   1.240 +}
   1.241 +
   1.242 +testmath("Math.abs", "void 0", Number.NaN)
   1.243 +testmath("Math.abs", "null", 0)
   1.244 +testmath("Math.abs", "true", 1)
   1.245 +testmath("Math.abs", "false", 0)
   1.246 +testmath("Math.abs", "\"a string primitive\"", Number.NaN)
   1.247 +testmath("Math.abs", "new String( 'a String object' )", Number.NaN)
   1.248 +testmath("Math.abs", "Number.NaN", Number.NaN)
   1.249 +testmath("Math.abs", "0", 0)
   1.250 +testmath("Math.abs", "-0", 0)
   1.251 +testmath("Infinity/Math.abs", "-0", Infinity)
   1.252 +testmath("Math.abs", "Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.253 +testmath("Math.abs", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.254 +testmath("Math.abs", "- Number.MAX_VALUE", Number.MAX_VALUE)
   1.255 +testmath("Math.abs", "-Number.MIN_VALUE", Number.MIN_VALUE)
   1.256 +testmath("Math.abs", "Number.MAX_VALUE", Number.MAX_VALUE)
   1.257 +testmath("Math.abs", "Number.MIN_VALUE", Number.MIN_VALUE)
   1.258 +testmath("Math.abs", "-1", 1)
   1.259 +testmath("Math.abs", "new Number(-1)", 1)
   1.260 +testmath("Math.abs", "1", 1)
   1.261 +testmath("Math.abs", "Math.PI", Math.PI)
   1.262 +testmath("Math.abs", "-Math.PI", Math.PI)
   1.263 +testmath("Math.abs", "-1/100000000", 1/100000000)
   1.264 +testmath("Math.abs", "-Math.pow(2,32)", Math.pow(2,32))
   1.265 +testmath("Math.abs", "Math.pow(2,32)", Math.pow(2,32))
   1.266 +testmath("Math.abs", "-0xfff", 4095)
   1.267 +testmath("Math.abs", "-0777", 511)
   1.268 +testmath("Math.abs", "'-1e-1'", 0.1)
   1.269 +testmath("Math.abs", "'0xff'", 255)
   1.270 +testmath("Math.abs", "'077'", 77)
   1.271 +testmath("Math.abs", "'Infinity'", Infinity)
   1.272 +testmath("Math.abs", "'-Infinity'", Infinity)
   1.273 +
   1.274 +testmath("Math.acos", "void 0", Number.NaN)
   1.275 +testmath("Math.acos", "null", Math.PI/2)
   1.276 +testmath("Math.acos", "Number.NaN", Number.NaN)
   1.277 +testmath("Math.acos", "\"a string\"", Number.NaN)
   1.278 +testmath("Math.acos", "'0'", Math.PI/2)
   1.279 +testmath("Math.acos", "'1'", 0)
   1.280 +testmath("Math.acos", "'-1'", Math.PI)
   1.281 +testmath("Math.acos", "1.00000001", Number.NaN)
   1.282 +testmath("Math.acos", "-1.00000001", Number.NaN)
   1.283 +testmath("Math.acos", "1", 0)
   1.284 +testmath("Math.acos", "-1", Math.PI)
   1.285 +testmath("Math.acos", "0", Math.PI/2)
   1.286 +testmath("Math.acos", "-0", Math.PI/2)
   1.287 +testmath("Math.acos", "Math.SQRT1_2", Math.PI/4)
   1.288 +testmath("Math.acos", "-Math.SQRT1_2", Math.PI/4*3)
   1.289 +testmath("Math.acos", "0.9999619230642", Math.PI/360)
   1.290 +testmath("Math.acos", "-3.0", Number.NaN)
   1.291 +
   1.292 +testmath("Math.asin", "void 0", Number.NaN)
   1.293 +testmath("Math.asin", "null", 0)
   1.294 +testmath("Math.asin", "Number.NaN", Number.NaN)
   1.295 +testmath("Math.asin", "\"string\"", Number.NaN)
   1.296 +testmath("Math.asin", "\"0\"", 0)
   1.297 +testmath("Math.asin", "\"1\"", Math.PI/2)
   1.298 +testmath("Math.asin", "\"-1\"", -Math.PI/2)
   1.299 +testmath("Math.asin", "Math.SQRT1_2+''", Math.PI/4)
   1.300 +testmath("Math.asin", "-Math.SQRT1_2+''", -Math.PI/4)
   1.301 +testmath("Math.asin", "1.000001", Number.NaN)
   1.302 +testmath("Math.asin", "-1.000001", Number.NaN)
   1.303 +testmath("Math.asin", "0", 0)
   1.304 +testmath("Math.asin", "-0", -0)
   1.305 +testmath("Infinity/Math.asin", "-0", -Infinity)
   1.306 +testmath("Math.asin", "1", Math.PI/2)
   1.307 +testmath("Math.asin", "-1", -Math.PI/2)
   1.308 +testmath("Math.asin", "Math.SQRT1_2", Math.PI/4)
   1.309 +testmath("Math.asin", "-Math.SQRT1_2", -Math.PI/4)
   1.310 +
   1.311 +testmath("Math.atan", "void 0", Number.NaN)
   1.312 +testmath("Math.atan", "null", 0)
   1.313 +testmath("Math.atan", "Number.NaN", Number.NaN)
   1.314 +testmath("Math.atan", "\"a string\"", Number.NaN)
   1.315 +testmath("Math.atan", "'0'", 0)
   1.316 +testmath("Math.atan", "'1'", Math.PI/4)
   1.317 +testmath("Math.atan", "'-1'", -Math.PI/4)
   1.318 +testmath("Math.atan", "'Infinity'", Math.PI/2)
   1.319 +testmath("Math.atan", "'-Infinity'", -Math.PI/2)
   1.320 +testmath("Math.atan", "0", 0)
   1.321 +testmath("Math.atan", "-0", -0)
   1.322 +testmath("Infinity/Math.atan", "-0", -Infinity)
   1.323 +testmath("Math.atan", "Number.POSITIVE_INFINITY", Math.PI/2)
   1.324 +testmath("Math.atan", "Number.NEGATIVE_INFINITY", -Math.PI/2)
   1.325 +testmath("Math.atan", "1", Math.PI/4)
   1.326 +testmath("Math.atan", "-1", -Math.PI/4)
   1.327 +
   1.328 +testmath("Math.atan2", "Number.NaN,0", Number.NaN)
   1.329 +testmath("Math.atan2", "null, null", 0)
   1.330 +testmath("Math.atan2", "void 0, void 0", Number.NaN)
   1.331 +testmath("Math.atan2", "0,Number.NaN", Number.NaN)
   1.332 +testmath("Math.atan2", "1,0", Math.PI/2)
   1.333 +testmath("Math.atan2", "1,-0", Math.PI/2)
   1.334 +testmath("Math.atan2", "0,0.001", 0)
   1.335 +testmath("Math.atan2", "0,0", 0)
   1.336 +testmath("Math.atan2", "0,-0", Math.PI)
   1.337 +testmath("Math.atan2", "0, -1", Math.PI)
   1.338 +testmath("Math.atan2", "-0, 1", -0)
   1.339 +testmath("Infinity/Math.atan2", "-0,1", -Infinity)
   1.340 +testmath("Math.atan2", "-0,0", -0)
   1.341 +testmath("Math.atan2", "-0, -0", -Math.PI)
   1.342 +testmath("Math.atan2", "-0, -1", -Math.PI)
   1.343 +testmath("Math.atan2", "-1, 0", -Math.PI/2)
   1.344 +testmath("Math.atan2", "-1, -0", -Math.PI/2)
   1.345 +testmath("Math.atan2", "1, Number.POSITIVE_INFINITY", 0)
   1.346 +testmath("Math.atan2", "1, Number.NEGATIVE_INFINITY", Math.PI)
   1.347 +testmath("Math.atan2", "-1,Number.POSITIVE_INFINITY", -0)
   1.348 +testmath("Infinity/Math.atan2", "-1,Infinity", -Infinity)
   1.349 +testmath("Math.atan2", "-1,Number.NEGATIVE_INFINITY", -Math.PI)
   1.350 +testmath("Math.atan2", "Number.POSITIVE_INFINITY, 0", Math.PI/2)
   1.351 +testmath("Math.atan2", "Number.POSITIVE_INFINITY, 1", Math.PI/2)
   1.352 +testmath("Math.atan2", "Number.POSITIVE_INFINITY,-1", Math.PI/2)
   1.353 +testmath("Math.atan2", "Number.POSITIVE_INFINITY,-0", Math.PI/2)
   1.354 +testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 0", -Math.PI/2)
   1.355 +testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-0", -Math.PI/2)
   1.356 +testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 1", -Math.PI/2)
   1.357 +testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-1", -Math.PI/2)
   1.358 +testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY", Math.PI/4)
   1.359 +testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY", 3*Math.PI/4)
   1.360 +testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", -Math.PI/4)
   1.361 +testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", -3*Math.PI/4)
   1.362 +testmath("Math.atan2", "-1, 1", -Math.PI/4)
   1.363 +
   1.364 +testmath("Math.ceil", "Number.NaN", Number.NaN)
   1.365 +testmath("Math.ceil", "null", 0)
   1.366 +testmath("Math.ceil", "void 0", Number.NaN)
   1.367 +testmath("Math.ceil", "'0'", 0)
   1.368 +testmath("Math.ceil", "'-0'", -0)
   1.369 +testmath("Infinity/Math.ceil", "'0'", Infinity)
   1.370 +testmath("Infinity/Math.ceil", "'-0'", -Infinity)
   1.371 +testmath("Math.ceil", "0", 0)
   1.372 +testmath("Math.ceil", "-0", -0)
   1.373 +testmath("Infinity/Math.ceil", "0", Infinity)
   1.374 +testmath("Infinity/Math.ceil", "-0", -Infinity)
   1.375 +testmath("Math.ceil", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.376 +testmath("Math.ceil", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   1.377 +testmath("Math.ceil", "-Number.MIN_VALUE", -0)
   1.378 +testmath("Infinity/Math.ceil", "-Number.MIN_VALUE", -Infinity)
   1.379 +testmath("Math.ceil", "1", 1)
   1.380 +testmath("Math.ceil", "-1", -1)
   1.381 +testmath("Math.ceil", "-0.9", -0)
   1.382 +testmath("Infinity/Math.ceil", "-0.9", -Infinity)
   1.383 +testmath("Math.ceil", "0.9", 1)
   1.384 +testmath("Math.ceil", "-1.1", -1)
   1.385 +testmath("Math.ceil", "1.1", 2)
   1.386 +testmath("Math.ceil", "Number.POSITIVE_INFINITY", -Math.floor(-Infinity))
   1.387 +testmath("Math.ceil", "Number.NEGATIVE_INFINITY", -Math.floor(Infinity))
   1.388 +testmath("Math.ceil", "-Number.MIN_VALUE", -Math.floor(Number.MIN_VALUE))
   1.389 +testmath("Math.ceil", "1", -Math.floor(-1))
   1.390 +testmath("Math.ceil", "-1", -Math.floor(1))
   1.391 +testmath("Math.ceil", "-0.9", -Math.floor(0.9))
   1.392 +testmath("Math.ceil", "0.9", -Math.floor(-0.9))
   1.393 +testmath("Math.ceil", "-1.1", -Math.floor(1.1))
   1.394 +testmath("Math.ceil", "1.1", -Math.floor(-1.1))
   1.395 +
   1.396 +testmath("Math.cos", "void 0", Number.NaN)
   1.397 +testmath("Math.cos", "false", 1)
   1.398 +testmath("Math.cos", "null", 1)
   1.399 +testmath("Math.cos", "'0'", 1)
   1.400 +testmath("Math.cos", "\"Infinity\"", Number.NaN)
   1.401 +testmath("Math.cos", "'3.14159265359'", -1)
   1.402 +testmath("Math.cos", "Number.NaN", Number.NaN)
   1.403 +testmath("Math.cos", "0", 1)
   1.404 +testmath("Math.cos", "-0", 1)
   1.405 +testmath("Math.cos", "Number.POSITIVE_INFINITY", Number.NaN)
   1.406 +testmath("Math.cos", "Number.NEGATIVE_INFINITY", Number.NaN)
   1.407 +testmath("Math.cos", "0.7853981633974", 0.7071067811865)
   1.408 +testmath("Math.cos", "1.570796326795", 0)
   1.409 +testmath("Math.cos", "2.356194490192", -0.7071067811865)
   1.410 +testmath("Math.cos", "3.14159265359", -1)
   1.411 +testmath("Math.cos", "3.926990816987", -0.7071067811865)
   1.412 +testmath("Math.cos", "4.712388980385", 0)
   1.413 +testmath("Math.cos", "5.497787143782", 0.7071067811865)
   1.414 +testmath("Math.cos", "Math.PI*2", 1)
   1.415 +testmath("Math.cos", "Math.PI/4", Math.SQRT2/2)
   1.416 +testmath("Math.cos", "Math.PI/2", 0)
   1.417 +testmath("Math.cos", "3*Math.PI/4", -Math.SQRT2/2)
   1.418 +testmath("Math.cos", "Math.PI", -1)
   1.419 +testmath("Math.cos", "5*Math.PI/4", -Math.SQRT2/2)
   1.420 +testmath("Math.cos", "3*Math.PI/2", 0)
   1.421 +testmath("Math.cos", "7*Math.PI/4", Math.SQRT2/2)
   1.422 +testmath("Math.cos", "2*Math.PI", 1)
   1.423 +testmath("Math.cos", "-0.7853981633974", 0.7071067811865)
   1.424 +testmath("Math.cos", "-1.570796326795", 0)
   1.425 +testmath("Math.cos", "2.3561944901920", -.7071067811865)
   1.426 +testmath("Math.cos", "3.14159265359", -1)
   1.427 +testmath("Math.cos", "3.926990816987", -0.7071067811865)
   1.428 +testmath("Math.cos", "4.712388980385", 0)
   1.429 +testmath("Math.cos", "5.497787143782", 0.7071067811865)
   1.430 +testmath("Math.cos", "6.28318530718", 1)
   1.431 +testmath("Math.cos", "-Math.PI/4", Math.SQRT2/2)
   1.432 +testmath("Math.cos", "-Math.PI/2", 0)
   1.433 +testmath("Math.cos", "-3*Math.PI/4", -Math.SQRT2/2)
   1.434 +testmath("Math.cos", "-Math.PI", -1)
   1.435 +testmath("Math.cos", "-5*Math.PI/4", -Math.SQRT2/2)
   1.436 +testmath("Math.cos", "-3*Math.PI/2", 0)
   1.437 +testmath("Math.cos", "-7*Math.PI/4", Math.SQRT2/2)
   1.438 +testmath("Math.cos", "-Math.PI*2", 1)
   1.439 +
   1.440 +testmath("Math.exp", "null", 1)
   1.441 +testmath("Math.exp", "void 0", Number.NaN)
   1.442 +testmath("Math.exp", "1", Math.E)
   1.443 +testmath("Math.exp", "true", Math.E)
   1.444 +testmath("Math.exp", "false", 1)
   1.445 +testmath("Math.exp", "'1'", Math.E)
   1.446 +testmath("Math.exp", "'0'", 1)
   1.447 +testmath("Math.exp", "Number.NaN", Number.NaN)
   1.448 +testmath("Math.exp", "0", 1)
   1.449 +testmath("Math.exp", "-0", 1)
   1.450 +testmath("Math.exp", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.451 +testmath("Math.exp", "Number.NEGATIVE_INFINITY", 0)
   1.452 +
   1.453 +testmath("Math.floor", "void 0", Number.NaN)
   1.454 +testmath("Math.floor", "null", 0)
   1.455 +testmath("Math.floor", "true", 1)
   1.456 +testmath("Math.floor", "false", 0)
   1.457 +testmath("Math.floor", "\"1.1\"", 1)
   1.458 +testmath("Math.floor", "\"-1.1\"", -2)
   1.459 +testmath("Math.floor", "\"0.1\"", 0)
   1.460 +testmath("Math.floor", "\"-0.1\"", -1)
   1.461 +testmath("Math.floor", "Number.NaN", Number.NaN)
   1.462 +testmath("Math.floor(Number.NaN) == -Math.ceil", "-Number.NaN", false)
   1.463 +testmath("Math.floor", "0", 0)
   1.464 +testmath("Math.floor(0) == -Math.ceil", "-0", true)
   1.465 +testmath("Math.floor", "-0", -0)
   1.466 +testmath("Infinity/Math.floor", "-0", -Infinity)
   1.467 +testmath("Math.floor(-0)== -Math.ceil", "0", true)
   1.468 +testmath("Math.floor", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.469 +testmath("Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil", "Number.NEGATIVE_INFINITY", true)
   1.470 +testmath("Math.floor", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   1.471 +testmath("Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil", "Number.POSITIVE_INFINITY", true)
   1.472 +testmath("Math.floor", "0.0000001", 0)
   1.473 +testmath("Math.floor(0.0000001)==-Math.ceil", "-0.0000001", true)
   1.474 +testmath("Math.floor", "-0.0000001", -1)
   1.475 +testmath("Math.floor(-0.0000001)==-Math.ceil", "0.0000001", true)
   1.476 +
   1.477 +testmath("Math.log", "void 0", Number.NaN)
   1.478 +testmath("Math.log", "null", Number.NEGATIVE_INFINITY)
   1.479 +testmath("Math.log", "true", 0)
   1.480 +testmath("Math.log", "false", -Infinity)
   1.481 +testmath("Math.log", "'0'", -Infinity)
   1.482 +testmath("Math.log", "'1'", 0)
   1.483 +testmath("Math.log", "\"Infinity\"", Infinity)
   1.484 +testmath("Math.log", "Number.NaN", Number.NaN)
   1.485 +testmath("Math.log", "-0.000001", Number.NaN)
   1.486 +testmath("Math.log", "-1", Number.NaN)
   1.487 +testmath("Math.log", "0", Number.NEGATIVE_INFINITY)
   1.488 +testmath("Math.log", "-0", Number.NEGATIVE_INFINITY)
   1.489 +testmath("Math.log", "1", 0)
   1.490 +testmath("Math.log", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.491 +testmath("Math.log", "Number.NEGATIVE_INFINITY", Number.NaN)
   1.492 +
   1.493 +testmath("Math.max", "void 0, 1", Number.NaN)
   1.494 +testmath("Math.max", "void 0, void 0", Number.NaN)
   1.495 +testmath("Math.max", "null, 1", 1)
   1.496 +testmath("Math.max", "-1, null", 0)
   1.497 +testmath("Math.max", "true,false", 1)
   1.498 +testmath("Math.max", "\"-99\",\"99\"", 99)
   1.499 +testmath("Math.max", "Number.NaN,Number.POSITIVE_INFINITY", Number.NaN)
   1.500 +testmath("Math.max", "Number.NaN, 0", Number.NaN)
   1.501 +testmath("Math.max", "\"a string\", 0", Number.NaN)
   1.502 +testmath("Math.max", "Number.NaN,1", Number.NaN)
   1.503 +testmath("Math.max", "\"a string\", Number.POSITIVE_INFINITY", Number.NaN)
   1.504 +testmath("Math.max", "Number.POSITIVE_INFINITY, Number.NaN", Number.NaN)
   1.505 +testmath("Math.max", "Number.NaN, Number.NaN", Number.NaN)
   1.506 +testmath("Math.max", "0,Number.NaN", Number.NaN)
   1.507 +testmath("Math.max", "1, Number.NaN", Number.NaN)
   1.508 +testmath("Math.max", "0,0", 0)
   1.509 +testmath("Math.max", "0,-0", 0)
   1.510 +testmath("Math.max", "-0,0", 0)
   1.511 +testmath("Math.max", "-0,-0", -0)
   1.512 +testmath("Infinity/Math.max", "-0,-0", -Infinity)
   1.513 +testmath("Math.max", "Number.POSITIVE_INFINITY, Number.MAX_VALUE", Number.POSITIVE_INFINITY)
   1.514 +testmath("Math.max", "Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.515 +testmath("Math.max", "Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   1.516 +testmath("Math.max", "1,.99999999999999", 1)
   1.517 +testmath("Math.max", "-1,-.99999999999999", -.99999999999999)
   1.518 +
   1.519 +testmath("Math.min", "void 0, 1", Number.NaN)
   1.520 +testmath("Math.min", "void 0, void 0", Number.NaN)
   1.521 +testmath("Math.min", "null, 1", 0)
   1.522 +testmath("Math.min", "-1, null", -1)
   1.523 +testmath("Math.min", "true,false", 0)
   1.524 +testmath("Math.min", "\"-99\",\"99\"", -99)
   1.525 +testmath("Math.min", "Number.NaN,0", Number.NaN)
   1.526 +testmath("Math.min", "Number.NaN,1", Number.NaN)
   1.527 +testmath("Math.min", "Number.NaN,-1", Number.NaN)
   1.528 +testmath("Math.min", "0,Number.NaN", Number.NaN)
   1.529 +testmath("Math.min", "1,Number.NaN", Number.NaN)
   1.530 +testmath("Math.min", "-1,Number.NaN", Number.NaN)
   1.531 +testmath("Math.min", "Number.NaN,Number.NaN", Number.NaN)
   1.532 +testmath("Math.min", "1,1.0000000001", 1)
   1.533 +testmath("Math.min", "1.0000000001,1", 1)
   1.534 +testmath("Math.min", "0,0", 0)
   1.535 +testmath("Math.min", "0,-0", -0)
   1.536 +testmath("Math.min", "-0,-0", -0)
   1.537 +testmath("Infinity/Math.min", "0,-0", -Infinity)
   1.538 +testmath("Infinity/Math.min", "-0,-0", -Infinity)
   1.539 +
   1.540 +testmath("Math.pow", "null,null", 1)
   1.541 +testmath("Math.pow", "void 0, void 0", Number.NaN)
   1.542 +testmath("Math.pow", "true, false", 1)
   1.543 +testmath("Math.pow", "false,true", 0)
   1.544 +testmath("Math.pow", "'2','32'", 4294967296)
   1.545 +testmath("Math.pow", "1,Number.NaN", Number.NaN)
   1.546 +testmath("Math.pow", "0,Number.NaN", Number.NaN)
   1.547 +testmath("Math.pow", "Number.NaN,0", 1)
   1.548 +testmath("Math.pow", "Number.NaN,-0", 1)
   1.549 +testmath("Math.pow", "Number.NaN, 1", Number.NaN)
   1.550 +testmath("Math.pow", "Number.NaN, .5", Number.NaN)
   1.551 +testmath("Math.pow", "1.00000001, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.552 +testmath("Math.pow", "1.00000001, Number.NEGATIVE_INFINITY", 0)
   1.553 +testmath("Math.pow", "-1.00000001,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.554 +testmath("Math.pow", "-1.00000001,Number.NEGATIVE_INFINITY", 0)
   1.555 +testmath("Math.pow", "1, Number.POSITIVE_INFINITY", Number.NaN)
   1.556 +testmath("Math.pow", "1, Number.NEGATIVE_INFINITY", Number.NaN)
   1.557 +testmath("Math.pow", "-1, Number.POSITIVE_INFINITY", Number.NaN)
   1.558 +testmath("Math.pow", "-1, Number.NEGATIVE_INFINITY", Number.NaN)
   1.559 +testmath("Math.pow", ".0000000009, Number.POSITIVE_INFINITY", 0)
   1.560 +testmath("Math.pow", "-.0000000009, Number.POSITIVE_INFINITY", 0)
   1.561 +testmath("Math.pow", "-.0000000009, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.562 +testmath("Math.pow", "Number.POSITIVE_INFINITY,.00000000001", Number.POSITIVE_INFINITY)
   1.563 +testmath("Math.pow", "Number.POSITIVE_INFINITY, 1", Number.POSITIVE_INFINITY)
   1.564 +testmath("Math.pow", "Number.POSITIVE_INFINITY, -.00000000001", 0)
   1.565 +testmath("Math.pow", "Number.POSITIVE_INFINITY, -1", 0)
   1.566 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, 1", Number.NEGATIVE_INFINITY)
   1.567 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, 333", Number.NEGATIVE_INFINITY)
   1.568 +testmath("Math.pow", "Number.POSITIVE_INFINITY, 2", Number.POSITIVE_INFINITY)
   1.569 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, 666", Number.POSITIVE_INFINITY)
   1.570 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, 0.5", Number.POSITIVE_INFINITY)
   1.571 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.572 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, -1", -0)
   1.573 +testmath("Infinity/Math.pow", "Number.NEGATIVE_INFINITY, -1", -Infinity)
   1.574 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, -3", -0)
   1.575 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, -2", 0)
   1.576 +testmath("Math.pow", "Number.NEGATIVE_INFINITY,-0.5", 0)
   1.577 +testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", 0)
   1.578 +testmath("Math.pow", "0,1", 0)
   1.579 +testmath("Math.pow", "0,0", 1)
   1.580 +testmath("Math.pow", "1,0", 1)
   1.581 +testmath("Math.pow", "-1,0", 1)
   1.582 +testmath("Math.pow", "0,0.5", 0)
   1.583 +testmath("Math.pow", "0,1000", 0)
   1.584 +testmath("Math.pow", "0, Number.POSITIVE_INFINITY", 0)
   1.585 +testmath("Math.pow", "0, -1", Number.POSITIVE_INFINITY)
   1.586 +testmath("Math.pow", "0, -0.5", Number.POSITIVE_INFINITY)
   1.587 +testmath("Math.pow", "0, -1000", Number.POSITIVE_INFINITY)
   1.588 +testmath("Math.pow", "0, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.589 +testmath("Math.pow", "-0, 1", -0)
   1.590 +testmath("Math.pow", "-0,3", -0)
   1.591 +testmath("Infinity/Math.pow", "-0, 1", -Infinity)
   1.592 +testmath("Infinity/Math.pow", "-0,3", -Infinity)
   1.593 +testmath("Math.pow", "-0,2", 0)
   1.594 +testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0)
   1.595 +testmath("Math.pow", "-0, -1", Number.NEGATIVE_INFINITY)
   1.596 +testmath("Math.pow", "-0, -10001", Number.NEGATIVE_INFINITY)
   1.597 +testmath("Math.pow", "-0, -2", Number.POSITIVE_INFINITY)
   1.598 +testmath("Math.pow", "-0, 0.5", 0)
   1.599 +testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0)
   1.600 +testmath("Math.pow", "-1, 0.5", Number.NaN)
   1.601 +testmath("Math.pow", "-1, Number.NaN", Number.NaN)
   1.602 +testmath("Math.pow", "-1, -0.5", Number.NaN)
   1.603 +
   1.604 +testmath("Math.round", "0", 0)
   1.605 +testmath("Math.round", "void 0", Number.NaN)
   1.606 +testmath("Math.round", "true", 1)
   1.607 +testmath("Math.round", "false", 0)
   1.608 +testmath("Math.round", "'.99999'", 1)
   1.609 +testmath("Math.round", "'12345e-2'", 123)
   1.610 +testmath("Math.round", "Number.NaN", Number.NaN)
   1.611 +testmath("Math.round", "0", 0)
   1.612 +testmath("Math.round", "-0", -0)
   1.613 +testmath("Infinity/Math.round", "-0", -Infinity)
   1.614 +testmath("Math.round", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.615 +testmath("Math.round", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   1.616 +testmath("Math.round", "0.49", 0)
   1.617 +testmath("Math.round", "0.5", 1)
   1.618 +testmath("Math.round", "0.51", 1)
   1.619 +testmath("Math.round", "-0.49", -0)
   1.620 +testmath("Math.round", "-0.5", -0)
   1.621 +testmath("Infinity/Math.round", "-0.49", -Infinity)
   1.622 +testmath("Infinity/Math.round", "-0.5", -Infinity)
   1.623 +testmath("Math.round", "-0.51", -1)
   1.624 +testmath("Math.round", "3.5", 4)
   1.625 +testmath("Math.round", "-3", -3)
   1.626 +
   1.627 +testmath("Math.sin", "null", 0)
   1.628 +testmath("Math.sin", "void 0", Number.NaN)
   1.629 +testmath("Math.sin", "false", 0)
   1.630 +testmath("Math.sin", "'2.356194490192'", 0.7071067811865)
   1.631 +testmath("Math.sin", "Number.NaN", Number.NaN)
   1.632 +testmath("Math.sin", "0", 0)
   1.633 +testmath("Math.sin", "-0", -0)
   1.634 +testmath("Math.sin", "Number.POSITIVE_INFINITY", Number.NaN)
   1.635 +testmath("Math.sin", "Number.NEGATIVE_INFINITY", Number.NaN)
   1.636 +testmath("Math.sin", "0.7853981633974", 0.7071067811865)
   1.637 +testmath("Math.sin", "1.570796326795", 1)
   1.638 +testmath("Math.sin", "2.356194490192", 0.7071067811865)
   1.639 +testmath("Math.sin", "3.14159265359", 0)
   1.640 +
   1.641 +testmath("Math.sqrt", "void 0", Number.NaN)
   1.642 +testmath("Math.sqrt", "null", 0)
   1.643 +testmath("Math.sqrt", "1", 1)
   1.644 +testmath("Math.sqrt", "false", 0)
   1.645 +testmath("Math.sqrt", "'225'", 15)
   1.646 +testmath("Math.sqrt", "Number.NaN", Number.NaN)
   1.647 +testmath("Math.sqrt", "Number.NEGATIVE_INFINITY", Number.NaN)
   1.648 +testmath("Math.sqrt", "-1", Number.NaN)
   1.649 +testmath("Math.sqrt", "-0.5", Number.NaN)
   1.650 +testmath("Math.sqrt", "0", 0)
   1.651 +testmath("Math.sqrt", "-0", -0)
   1.652 +testmath("Infinity/Math.sqrt", "-0", -Infinity)
   1.653 +testmath("Math.sqrt", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   1.654 +testmath("Math.sqrt", "1", 1)
   1.655 +testmath("Math.sqrt", "2", Math.SQRT2)
   1.656 +testmath("Math.sqrt", "0.5", Math.SQRT1_2)
   1.657 +testmath("Math.sqrt", "4", 2)
   1.658 +testmath("Math.sqrt", "9", 3)
   1.659 +testmath("Math.sqrt", "16", 4)
   1.660 +testmath("Math.sqrt", "25", 5)
   1.661 +testmath("Math.sqrt", "36", 6)
   1.662 +testmath("Math.sqrt", "49", 7)
   1.663 +testmath("Math.sqrt", "64", 8)
   1.664 +testmath("Math.sqrt", "256", 16)
   1.665 +testmath("Math.sqrt", "10000", 100)
   1.666 +testmath("Math.sqrt", "65536", 256)
   1.667 +testmath("Math.sqrt", "0.09", 0.3)
   1.668 +testmath("Math.sqrt", "0.01", 0.1)
   1.669 +testmath("Math.sqrt", "0.00000001", 0.0001)
   1.670 +
   1.671 +testmath("Math.tan", "void 0", Number.NaN)
   1.672 +testmath("Math.tan", "null", 0)
   1.673 +testmath("Math.tan", "false", 0)
   1.674 +testmath("Math.tan", "Number.NaN", Number.NaN)
   1.675 +testmath("Math.tan", "0", 0)
   1.676 +testmath("Math.tan", "-0", -0)
   1.677 +testmath("Math.tan", "Number.POSITIVE_INFINITY", Number.NaN)
   1.678 +testmath("Math.tan", "Number.NEGATIVE_INFINITY", Number.NaN)
   1.679 +testmath("Math.tan", "Math.PI/4", 1)
   1.680 +testmath("Math.tan", "3*Math.PI/4", -1)
   1.681 +testmath("Math.tan", "Math.PI", -0)
   1.682 +testmath("Math.tan", "5*Math.PI/4", 1)
   1.683 +testmath("Math.tan", "7*Math.PI/4", -1)
   1.684 +testmath("Infinity/Math.tan", "-0", -Infinity)
   1.685 +
   1.686 +jit(false);
   1.687 +
   1.688 +/* Keep these at the end so that we can see the summary after the trace-debug spew. */
   1.689 +if (0) {
   1.690 +  print("\npassed:", passes.length && passes.join(","));
   1.691 +  print("\nFAILED:", fails.length && fails.join(","));
   1.692 +}

mercurial