js/src/jit-test/tests/basic/math-jit-tests.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     3 // Apply FUNCNAME to ARGS, and check against EXPECTED.
     4 // Expect a loop containing such a call to be traced.
     5 // FUNCNAME and ARGS are both strings.
     6 // ARGS has the form of an argument list: a comma-separated list of expressions.
     7 // Certain Tracemonkey limitations require us to pass FUNCNAME as a string.
     8 // Passing ARGS as a string allows us to assign better test names:
     9 // expressions like Math.PI/4 haven't been evaluated to big hairy numbers.
    10 function testmath(funcname, args, expected) {
    11     var i, j;
    13     var arg_value_list = eval("[" + args + "]");
    14     var arity = arg_value_list.length;
    16     // Build the string "a[i][0],...,a[i][ARITY-1]".
    17     var actuals = []
    18     for (i = 0; i < arity; i++)
    19         actuals.push("a[i][" + i + "]");
    20     actuals = actuals.join(",");
    22     // Create a function that maps FUNCNAME across an array of input values.
    23     // Unless we eval here, the call to funcname won't get traced.
    24     // FUNCNAME="Infinity/Math.abs" and cases like that happen to
    25     // parse, too, in a twisted way.
    26     var mapfunc = eval("(function(a) {\n"
    27                        + "   for (var i = 0; i < a.length; i++)\n"
    28                        + "       a[i] = " + funcname + "(" + actuals +");\n"
    29                        + " })\n");
    31     // To prevent the compiler from doing constant folding, produce an
    32     // array to pass to mapfunc that contains enough dummy
    33     // values at the front to get the loop body jitted, and then our
    34     // actual test value.
    35     var dummies_and_input = [];
    36     for (i = 0; i < 9; i++) {
    37         var dummy_list = [];
    38         for (j = 0; j < arity; j++)
    39             dummy_list[j] = .0078125 * ((i + j) % 128);
    40         dummies_and_input[i] = dummy_list;
    41     }
    42     dummies_and_input[9] = arg_value_list;
    44     function testfunc() {
    45         // Map the function across the dummy values and the test input.
    46         mapfunc(dummies_and_input);
    47         return dummies_and_input[9];
    48     }
    50     assertEq(close_enough(testfunc(), expected), true);
    51 }
    53 function close_enough(expected, actual)
    54 {
    55   if (typeof expected != typeof actual)
    56     return false;
    57   if (typeof expected != 'number')
    58     return actual == expected;
    60   // Distinguish NaN from other values.  Using x != x comparisons here
    61   // works even if tests redefine isNaN.
    62   if (actual != actual)
    63     return expected != expected
    64   if (expected != expected)
    65     return false;
    67   // Tolerate a certain degree of error.
    68   if (actual != expected)
    69     return Math.abs(actual - expected) <= 1E-10;
    71   // Distinguish 0 and -0.
    72   if (actual == 0)
    73     return (1 / actual > 0) == (1 / expected > 0);
    75   return true;
    76 }
    78 testmath("Math.abs", "void 0", Number.NaN)
    79 testmath("Math.abs", "null", 0)
    80 testmath("Math.abs", "true", 1)
    81 testmath("Math.abs", "false", 0)
    82 testmath("Math.abs", "\"a string primitive\"", Number.NaN)
    83 testmath("Math.abs", "new String( 'a String object' )", Number.NaN)
    84 testmath("Math.abs", "Number.NaN", Number.NaN)
    85 testmath("Math.abs", "0", 0)
    86 testmath("Math.abs", "-0", 0)
    87 testmath("Infinity/Math.abs", "-0", Infinity)
    88 testmath("Math.abs", "Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
    89 testmath("Math.abs", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
    90 testmath("Math.abs", "- Number.MAX_VALUE", Number.MAX_VALUE)
    91 testmath("Math.abs", "-Number.MIN_VALUE", Number.MIN_VALUE)
    92 testmath("Math.abs", "Number.MAX_VALUE", Number.MAX_VALUE)
    93 testmath("Math.abs", "Number.MIN_VALUE", Number.MIN_VALUE)
    94 testmath("Math.abs", "-1", 1)
    95 testmath("Math.abs", "new Number(-1)", 1)
    96 testmath("Math.abs", "1", 1)
    97 testmath("Math.abs", "Math.PI", Math.PI)
    98 testmath("Math.abs", "-Math.PI", Math.PI)
    99 testmath("Math.abs", "-1/100000000", 1/100000000)
   100 testmath("Math.abs", "-Math.pow(2,32)", Math.pow(2,32))
   101 testmath("Math.abs", "Math.pow(2,32)", Math.pow(2,32))
   102 testmath("Math.abs", "-0xfff", 4095)
   103 testmath("Math.abs", "-0777", 511)
   104 testmath("Math.abs", "'-1e-1'", 0.1)
   105 testmath("Math.abs", "'0xff'", 255)
   106 testmath("Math.abs", "'077'", 77)
   107 testmath("Math.abs", "'Infinity'", Infinity)
   108 testmath("Math.abs", "'-Infinity'", Infinity)
   110 testmath("Math.acos", "void 0", Number.NaN)
   111 testmath("Math.acos", "null", Math.PI/2)
   112 testmath("Math.acos", "Number.NaN", Number.NaN)
   113 testmath("Math.acos", "\"a string\"", Number.NaN)
   114 testmath("Math.acos", "'0'", Math.PI/2)
   115 testmath("Math.acos", "'1'", 0)
   116 testmath("Math.acos", "'-1'", Math.PI)
   117 testmath("Math.acos", "1.00000001", Number.NaN)
   118 testmath("Math.acos", "-1.00000001", Number.NaN)
   119 testmath("Math.acos", "1", 0)
   120 testmath("Math.acos", "-1", Math.PI)
   121 testmath("Math.acos", "0", Math.PI/2)
   122 testmath("Math.acos", "-0", Math.PI/2)
   123 testmath("Math.acos", "Math.SQRT1_2", Math.PI/4)
   124 testmath("Math.acos", "-Math.SQRT1_2", Math.PI/4*3)
   125 testmath("Math.acos", "0.9999619230642", Math.PI/360)
   126 testmath("Math.acos", "-3.0", Number.NaN)
   128 testmath("Math.asin", "void 0", Number.NaN)
   129 testmath("Math.asin", "null", 0)
   130 testmath("Math.asin", "Number.NaN", Number.NaN)
   131 testmath("Math.asin", "\"string\"", Number.NaN)
   132 testmath("Math.asin", "\"0\"", 0)
   133 testmath("Math.asin", "\"1\"", Math.PI/2)
   134 testmath("Math.asin", "\"-1\"", -Math.PI/2)
   135 testmath("Math.asin", "Math.SQRT1_2+''", Math.PI/4)
   136 testmath("Math.asin", "-Math.SQRT1_2+''", -Math.PI/4)
   137 testmath("Math.asin", "1.000001", Number.NaN)
   138 testmath("Math.asin", "-1.000001", Number.NaN)
   139 testmath("Math.asin", "0", 0)
   140 testmath("Math.asin", "-0", -0)
   141 testmath("Infinity/Math.asin", "-0", -Infinity)
   142 testmath("Math.asin", "1", Math.PI/2)
   143 testmath("Math.asin", "-1", -Math.PI/2)
   144 testmath("Math.asin", "Math.SQRT1_2", Math.PI/4)
   145 testmath("Math.asin", "-Math.SQRT1_2", -Math.PI/4)
   147 testmath("Math.atan", "void 0", Number.NaN)
   148 testmath("Math.atan", "null", 0)
   149 testmath("Math.atan", "Number.NaN", Number.NaN)
   150 testmath("Math.atan", "\"a string\"", Number.NaN)
   151 testmath("Math.atan", "'0'", 0)
   152 testmath("Math.atan", "'1'", Math.PI/4)
   153 testmath("Math.atan", "'-1'", -Math.PI/4)
   154 testmath("Math.atan", "'Infinity'", Math.PI/2)
   155 testmath("Math.atan", "'-Infinity'", -Math.PI/2)
   156 testmath("Math.atan", "0", 0)
   157 testmath("Math.atan", "-0", -0)
   158 testmath("Infinity/Math.atan", "-0", -Infinity)
   159 testmath("Math.atan", "Number.POSITIVE_INFINITY", Math.PI/2)
   160 testmath("Math.atan", "Number.NEGATIVE_INFINITY", -Math.PI/2)
   161 testmath("Math.atan", "1", Math.PI/4)
   162 testmath("Math.atan", "-1", -Math.PI/4)
   164 testmath("Math.atan2", "Number.NaN,0", Number.NaN)
   165 testmath("Math.atan2", "null, null", 0)
   166 testmath("Math.atan2", "void 0, void 0", Number.NaN)
   167 testmath("Math.atan2", "0,Number.NaN", Number.NaN)
   168 testmath("Math.atan2", "1,0", Math.PI/2)
   169 testmath("Math.atan2", "1,-0", Math.PI/2)
   170 testmath("Math.atan2", "0,0.001", 0)
   171 testmath("Math.atan2", "0,0", 0)
   172 testmath("Math.atan2", "0,-0", Math.PI)
   173 testmath("Math.atan2", "0, -1", Math.PI)
   174 testmath("Math.atan2", "-0, 1", -0)
   175 testmath("Infinity/Math.atan2", "-0,1", -Infinity)
   176 testmath("Math.atan2", "-0,0", -0)
   177 testmath("Math.atan2", "-0, -0", -Math.PI)
   178 testmath("Math.atan2", "-0, -1", -Math.PI)
   179 testmath("Math.atan2", "-1, 0", -Math.PI/2)
   180 testmath("Math.atan2", "-1, -0", -Math.PI/2)
   181 testmath("Math.atan2", "1, Number.POSITIVE_INFINITY", 0)
   182 testmath("Math.atan2", "1, Number.NEGATIVE_INFINITY", Math.PI)
   183 testmath("Math.atan2", "-1,Number.POSITIVE_INFINITY", -0)
   184 testmath("Infinity/Math.atan2", "-1,Infinity", -Infinity)
   185 testmath("Math.atan2", "-1,Number.NEGATIVE_INFINITY", -Math.PI)
   186 testmath("Math.atan2", "Number.POSITIVE_INFINITY, 0", Math.PI/2)
   187 testmath("Math.atan2", "Number.POSITIVE_INFINITY, 1", Math.PI/2)
   188 testmath("Math.atan2", "Number.POSITIVE_INFINITY,-1", Math.PI/2)
   189 testmath("Math.atan2", "Number.POSITIVE_INFINITY,-0", Math.PI/2)
   190 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 0", -Math.PI/2)
   191 testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-0", -Math.PI/2)
   192 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 1", -Math.PI/2)
   193 testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-1", -Math.PI/2)
   194 testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY", Math.PI/4)
   195 testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY", 3*Math.PI/4)
   196 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", -Math.PI/4)
   197 testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", -3*Math.PI/4)
   198 testmath("Math.atan2", "-1, 1", -Math.PI/4)
   200 testmath("Math.ceil", "Number.NaN", Number.NaN)
   201 testmath("Math.ceil", "null", 0)
   202 testmath("Math.ceil", "void 0", Number.NaN)
   203 testmath("Math.ceil", "'0'", 0)
   204 testmath("Math.ceil", "'-0'", -0)
   205 testmath("Infinity/Math.ceil", "'0'", Infinity)
   206 testmath("Infinity/Math.ceil", "'-0'", -Infinity)
   207 testmath("Math.ceil", "0", 0)
   208 testmath("Math.ceil", "-0", -0)
   209 testmath("Infinity/Math.ceil", "0", Infinity)
   210 testmath("Infinity/Math.ceil", "-0", -Infinity)
   211 testmath("Math.ceil", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   212 testmath("Math.ceil", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   213 testmath("Math.ceil", "-Number.MIN_VALUE", -0)
   214 testmath("Infinity/Math.ceil", "-Number.MIN_VALUE", -Infinity)
   215 testmath("Math.ceil", "1", 1)
   216 testmath("Math.ceil", "-1", -1)
   217 testmath("Math.ceil", "-0.9", -0)
   218 testmath("Infinity/Math.ceil", "-0.9", -Infinity)
   219 testmath("Math.ceil", "0.9", 1)
   220 testmath("Math.ceil", "-1.1", -1)
   221 testmath("Math.ceil", "1.1", 2)
   222 testmath("Math.ceil", "Number.POSITIVE_INFINITY", -Math.floor(-Infinity))
   223 testmath("Math.ceil", "Number.NEGATIVE_INFINITY", -Math.floor(Infinity))
   224 testmath("Math.ceil", "-Number.MIN_VALUE", -Math.floor(Number.MIN_VALUE))
   225 testmath("Math.ceil", "1", -Math.floor(-1))
   226 testmath("Math.ceil", "-1", -Math.floor(1))
   227 testmath("Math.ceil", "-0.9", -Math.floor(0.9))
   228 testmath("Math.ceil", "0.9", -Math.floor(-0.9))
   229 testmath("Math.ceil", "-1.1", -Math.floor(1.1))
   230 testmath("Math.ceil", "1.1", -Math.floor(-1.1))
   232 testmath("Math.cos", "void 0", Number.NaN)
   233 testmath("Math.cos", "false", 1)
   234 testmath("Math.cos", "null", 1)
   235 testmath("Math.cos", "'0'", 1)
   236 testmath("Math.cos", "\"Infinity\"", Number.NaN)
   237 testmath("Math.cos", "'3.14159265359'", -1)
   238 testmath("Math.cos", "Number.NaN", Number.NaN)
   239 testmath("Math.cos", "0", 1)
   240 testmath("Math.cos", "-0", 1)
   241 testmath("Math.cos", "Number.POSITIVE_INFINITY", Number.NaN)
   242 testmath("Math.cos", "Number.NEGATIVE_INFINITY", Number.NaN)
   243 testmath("Math.cos", "0.7853981633974", 0.7071067811865)
   244 testmath("Math.cos", "1.570796326795", 0)
   245 testmath("Math.cos", "2.356194490192", -0.7071067811865)
   246 testmath("Math.cos", "3.14159265359", -1)
   247 testmath("Math.cos", "3.926990816987", -0.7071067811865)
   248 testmath("Math.cos", "4.712388980385", 0)
   249 testmath("Math.cos", "5.497787143782", 0.7071067811865)
   250 testmath("Math.cos", "Math.PI*2", 1)
   251 testmath("Math.cos", "Math.PI/4", Math.SQRT2/2)
   252 testmath("Math.cos", "Math.PI/2", 0)
   253 testmath("Math.cos", "3*Math.PI/4", -Math.SQRT2/2)
   254 testmath("Math.cos", "Math.PI", -1)
   255 testmath("Math.cos", "5*Math.PI/4", -Math.SQRT2/2)
   256 testmath("Math.cos", "3*Math.PI/2", 0)
   257 testmath("Math.cos", "7*Math.PI/4", Math.SQRT2/2)
   258 testmath("Math.cos", "2*Math.PI", 1)
   259 testmath("Math.cos", "-0.7853981633974", 0.7071067811865)
   260 testmath("Math.cos", "-1.570796326795", 0)
   261 testmath("Math.cos", "2.3561944901920", -.7071067811865)
   262 testmath("Math.cos", "3.14159265359", -1)
   263 testmath("Math.cos", "3.926990816987", -0.7071067811865)
   264 testmath("Math.cos", "4.712388980385", 0)
   265 testmath("Math.cos", "5.497787143782", 0.7071067811865)
   266 testmath("Math.cos", "6.28318530718", 1)
   267 testmath("Math.cos", "-Math.PI/4", Math.SQRT2/2)
   268 testmath("Math.cos", "-Math.PI/2", 0)
   269 testmath("Math.cos", "-3*Math.PI/4", -Math.SQRT2/2)
   270 testmath("Math.cos", "-Math.PI", -1)
   271 testmath("Math.cos", "-5*Math.PI/4", -Math.SQRT2/2)
   272 testmath("Math.cos", "-3*Math.PI/2", 0)
   273 testmath("Math.cos", "-7*Math.PI/4", Math.SQRT2/2)
   274 testmath("Math.cos", "-Math.PI*2", 1)
   276 testmath("Math.exp", "null", 1)
   277 testmath("Math.exp", "void 0", Number.NaN)
   278 testmath("Math.exp", "1", Math.E)
   279 testmath("Math.exp", "true", Math.E)
   280 testmath("Math.exp", "false", 1)
   281 testmath("Math.exp", "'1'", Math.E)
   282 testmath("Math.exp", "'0'", 1)
   283 testmath("Math.exp", "Number.NaN", Number.NaN)
   284 testmath("Math.exp", "0", 1)
   285 testmath("Math.exp", "-0", 1)
   286 testmath("Math.exp", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   287 testmath("Math.exp", "Number.NEGATIVE_INFINITY", 0)
   289 testmath("Math.floor", "void 0", Number.NaN)
   290 testmath("Math.floor", "null", 0)
   291 testmath("Math.floor", "true", 1)
   292 testmath("Math.floor", "false", 0)
   293 testmath("Math.floor", "\"1.1\"", 1)
   294 testmath("Math.floor", "\"-1.1\"", -2)
   295 testmath("Math.floor", "\"0.1\"", 0)
   296 testmath("Math.floor", "\"-0.1\"", -1)
   297 testmath("Math.floor", "Number.NaN", Number.NaN)
   298 testmath("Math.floor(Number.NaN) == -Math.ceil", "-Number.NaN", false)
   299 testmath("Math.floor", "0", 0)
   300 testmath("Math.floor(0) == -Math.ceil", "-0", true)
   301 testmath("Math.floor", "-0", -0)
   302 testmath("Infinity/Math.floor", "-0", -Infinity)
   303 testmath("Math.floor(-0)== -Math.ceil", "0", true)
   304 testmath("Math.floor", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   305 testmath("Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil", "Number.NEGATIVE_INFINITY", true)
   306 testmath("Math.floor", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   307 testmath("Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil", "Number.POSITIVE_INFINITY", true)
   308 testmath("Math.floor", "0.0000001", 0)
   309 testmath("Math.floor(0.0000001)==-Math.ceil", "-0.0000001", true)
   310 testmath("Math.floor", "-0.0000001", -1)
   311 testmath("Math.floor(-0.0000001)==-Math.ceil", "0.0000001", true)
   313 testmath("Math.log", "void 0", Number.NaN)
   314 testmath("Math.log", "null", Number.NEGATIVE_INFINITY)
   315 testmath("Math.log", "true", 0)
   316 testmath("Math.log", "false", -Infinity)
   317 testmath("Math.log", "'0'", -Infinity)
   318 testmath("Math.log", "'1'", 0)
   319 testmath("Math.log", "\"Infinity\"", Infinity)
   320 testmath("Math.log", "Number.NaN", Number.NaN)
   321 testmath("Math.log", "-0.000001", Number.NaN)
   322 testmath("Math.log", "-1", Number.NaN)
   323 testmath("Math.log", "0", Number.NEGATIVE_INFINITY)
   324 testmath("Math.log", "-0", Number.NEGATIVE_INFINITY)
   325 testmath("Math.log", "1", 0)
   326 testmath("Math.log", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   327 testmath("Math.log", "Number.NEGATIVE_INFINITY", Number.NaN)
   329 testmath("Math.max", "void 0, 1", Number.NaN)
   330 testmath("Math.max", "void 0, void 0", Number.NaN)
   331 testmath("Math.max", "null, 1", 1)
   332 testmath("Math.max", "-1, null", 0)
   333 testmath("Math.max", "true,false", 1)
   334 testmath("Math.max", "\"-99\",\"99\"", 99)
   335 testmath("Math.max", "Number.NaN,Number.POSITIVE_INFINITY", Number.NaN)
   336 testmath("Math.max", "Number.NaN, 0", Number.NaN)
   337 testmath("Math.max", "\"a string\", 0", Number.NaN)
   338 testmath("Math.max", "Number.NaN,1", Number.NaN)
   339 testmath("Math.max", "\"a string\", Number.POSITIVE_INFINITY", Number.NaN)
   340 testmath("Math.max", "Number.POSITIVE_INFINITY, Number.NaN", Number.NaN)
   341 testmath("Math.max", "Number.NaN, Number.NaN", Number.NaN)
   342 testmath("Math.max", "0,Number.NaN", Number.NaN)
   343 testmath("Math.max", "1, Number.NaN", Number.NaN)
   344 testmath("Math.max", "0,0", 0)
   345 testmath("Math.max", "0,-0", 0)
   346 testmath("Math.max", "-0,0", 0)
   347 testmath("Math.max", "-0,-0", -0)
   348 testmath("Infinity/Math.max", "-0,-0", -Infinity)
   349 testmath("Math.max", "Number.POSITIVE_INFINITY, Number.MAX_VALUE", Number.POSITIVE_INFINITY)
   350 testmath("Math.max", "Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   351 testmath("Math.max", "Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   352 testmath("Math.max", "1,.99999999999999", 1)
   353 testmath("Math.max", "-1,-.99999999999999", -.99999999999999)
   355 testmath("Math.min", "void 0, 1", Number.NaN)
   356 testmath("Math.min", "void 0, void 0", Number.NaN)
   357 testmath("Math.min", "null, 1", 0)
   358 testmath("Math.min", "-1, null", -1)
   359 testmath("Math.min", "true,false", 0)
   360 testmath("Math.min", "\"-99\",\"99\"", -99)
   361 testmath("Math.min", "Number.NaN,0", Number.NaN)
   362 testmath("Math.min", "Number.NaN,1", Number.NaN)
   363 testmath("Math.min", "Number.NaN,-1", Number.NaN)
   364 testmath("Math.min", "0,Number.NaN", Number.NaN)
   365 testmath("Math.min", "1,Number.NaN", Number.NaN)
   366 testmath("Math.min", "-1,Number.NaN", Number.NaN)
   367 testmath("Math.min", "Number.NaN,Number.NaN", Number.NaN)
   368 testmath("Math.min", "1,1.0000000001", 1)
   369 testmath("Math.min", "1.0000000001,1", 1)
   370 testmath("Math.min", "0,0", 0)
   371 testmath("Math.min", "0,-0", -0)
   372 testmath("Math.min", "-0,-0", -0)
   373 testmath("Infinity/Math.min", "0,-0", -Infinity)
   374 testmath("Infinity/Math.min", "-0,-0", -Infinity)
   376 testmath("Math.pow", "null,null", 1)
   377 testmath("Math.pow", "void 0, void 0", Number.NaN)
   378 testmath("Math.pow", "true, false", 1)
   379 testmath("Math.pow", "false,true", 0)
   380 testmath("Math.pow", "'2','32'", 4294967296)
   381 testmath("Math.pow", "1,Number.NaN", Number.NaN)
   382 testmath("Math.pow", "0,Number.NaN", Number.NaN)
   383 testmath("Math.pow", "Number.NaN,0", 1)
   384 testmath("Math.pow", "Number.NaN,-0", 1)
   385 testmath("Math.pow", "Number.NaN, 1", Number.NaN)
   386 testmath("Math.pow", "Number.NaN, .5", Number.NaN)
   387 testmath("Math.pow", "1.00000001, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   388 testmath("Math.pow", "1.00000001, Number.NEGATIVE_INFINITY", 0)
   389 testmath("Math.pow", "-1.00000001,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   390 testmath("Math.pow", "-1.00000001,Number.NEGATIVE_INFINITY", 0)
   391 testmath("Math.pow", "1, Number.POSITIVE_INFINITY", Number.NaN)
   392 testmath("Math.pow", "1, Number.NEGATIVE_INFINITY", Number.NaN)
   393 testmath("Math.pow", "-1, Number.POSITIVE_INFINITY", Number.NaN)
   394 testmath("Math.pow", "-1, Number.NEGATIVE_INFINITY", Number.NaN)
   395 testmath("Math.pow", ".0000000009, Number.POSITIVE_INFINITY", 0)
   396 testmath("Math.pow", "-.0000000009, Number.POSITIVE_INFINITY", 0)
   397 testmath("Math.pow", "-.0000000009, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
   398 testmath("Math.pow", "Number.POSITIVE_INFINITY,.00000000001", Number.POSITIVE_INFINITY)
   399 testmath("Math.pow", "Number.POSITIVE_INFINITY, 1", Number.POSITIVE_INFINITY)
   400 testmath("Math.pow", "Number.POSITIVE_INFINITY, -.00000000001", 0)
   401 testmath("Math.pow", "Number.POSITIVE_INFINITY, -1", 0)
   402 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 1", Number.NEGATIVE_INFINITY)
   403 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 333", Number.NEGATIVE_INFINITY)
   404 testmath("Math.pow", "Number.POSITIVE_INFINITY, 2", Number.POSITIVE_INFINITY)
   405 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 666", Number.POSITIVE_INFINITY)
   406 testmath("Math.pow", "Number.NEGATIVE_INFINITY, 0.5", Number.POSITIVE_INFINITY)
   407 testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   408 testmath("Math.pow", "Number.NEGATIVE_INFINITY, -1", -0)
   409 testmath("Infinity/Math.pow", "Number.NEGATIVE_INFINITY, -1", -Infinity)
   410 testmath("Math.pow", "Number.NEGATIVE_INFINITY, -3", -0)
   411 testmath("Math.pow", "Number.NEGATIVE_INFINITY, -2", 0)
   412 testmath("Math.pow", "Number.NEGATIVE_INFINITY,-0.5", 0)
   413 testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", 0)
   414 testmath("Math.pow", "0,1", 0)
   415 testmath("Math.pow", "0,0", 1)
   416 testmath("Math.pow", "1,0", 1)
   417 testmath("Math.pow", "-1,0", 1)
   418 testmath("Math.pow", "0,0.5", 0)
   419 testmath("Math.pow", "0,1000", 0)
   420 testmath("Math.pow", "0, Number.POSITIVE_INFINITY", 0)
   421 testmath("Math.pow", "0, -1", Number.POSITIVE_INFINITY)
   422 testmath("Math.pow", "0, -0.5", Number.POSITIVE_INFINITY)
   423 testmath("Math.pow", "0, -1000", Number.POSITIVE_INFINITY)
   424 testmath("Math.pow", "0, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY)
   425 testmath("Math.pow", "-0, 1", -0)
   426 testmath("Math.pow", "-0,3", -0)
   427 testmath("Infinity/Math.pow", "-0, 1", -Infinity)
   428 testmath("Infinity/Math.pow", "-0,3", -Infinity)
   429 testmath("Math.pow", "-0,2", 0)
   430 testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0)
   431 testmath("Math.pow", "-0, -1", Number.NEGATIVE_INFINITY)
   432 testmath("Math.pow", "-0, -10001", Number.NEGATIVE_INFINITY)
   433 testmath("Math.pow", "-0, -2", Number.POSITIVE_INFINITY)
   434 testmath("Math.pow", "-0, 0.5", 0)
   435 testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0)
   436 testmath("Math.pow", "-1, 0.5", Number.NaN)
   437 testmath("Math.pow", "-1, Number.NaN", Number.NaN)
   438 testmath("Math.pow", "-1, -0.5", Number.NaN)
   440 testmath("Math.round", "0", 0)
   441 testmath("Math.round", "void 0", Number.NaN)
   442 testmath("Math.round", "true", 1)
   443 testmath("Math.round", "false", 0)
   444 testmath("Math.round", "'.99999'", 1)
   445 testmath("Math.round", "'12345e-2'", 123)
   446 testmath("Math.round", "Number.NaN", Number.NaN)
   447 testmath("Math.round", "0", 0)
   448 testmath("Math.round", "-0", -0)
   449 testmath("Infinity/Math.round", "-0", -Infinity)
   450 testmath("Math.round", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   451 testmath("Math.round", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY)
   452 testmath("Math.round", "0.49", 0)
   453 testmath("Math.round", "0.5", 1)
   454 testmath("Math.round", "0.51", 1)
   455 testmath("Math.round", "-0.49", -0)
   456 testmath("Math.round", "-0.5", -0)
   457 testmath("Infinity/Math.round", "-0.49", -Infinity)
   458 testmath("Infinity/Math.round", "-0.5", -Infinity)
   459 testmath("Math.round", "-0.51", -1)
   460 testmath("Math.round", "3.5", 4)
   461 testmath("Math.round", "-3", -3)
   463 testmath("Math.sin", "null", 0)
   464 testmath("Math.sin", "void 0", Number.NaN)
   465 testmath("Math.sin", "false", 0)
   466 testmath("Math.sin", "'2.356194490192'", 0.7071067811865)
   467 testmath("Math.sin", "Number.NaN", Number.NaN)
   468 testmath("Math.sin", "0", 0)
   469 testmath("Math.sin", "-0", -0)
   470 testmath("Math.sin", "Number.POSITIVE_INFINITY", Number.NaN)
   471 testmath("Math.sin", "Number.NEGATIVE_INFINITY", Number.NaN)
   472 testmath("Math.sin", "0.7853981633974", 0.7071067811865)
   473 testmath("Math.sin", "1.570796326795", 1)
   474 testmath("Math.sin", "2.356194490192", 0.7071067811865)
   475 testmath("Math.sin", "3.14159265359", 0)
   477 testmath("Math.sqrt", "void 0", Number.NaN)
   478 testmath("Math.sqrt", "null", 0)
   479 testmath("Math.sqrt", "1", 1)
   480 testmath("Math.sqrt", "false", 0)
   481 testmath("Math.sqrt", "'225'", 15)
   482 testmath("Math.sqrt", "Number.NaN", Number.NaN)
   483 testmath("Math.sqrt", "Number.NEGATIVE_INFINITY", Number.NaN)
   484 testmath("Math.sqrt", "-1", Number.NaN)
   485 testmath("Math.sqrt", "-0.5", Number.NaN)
   486 testmath("Math.sqrt", "0", 0)
   487 testmath("Math.sqrt", "-0", -0)
   488 testmath("Infinity/Math.sqrt", "-0", -Infinity)
   489 testmath("Math.sqrt", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY)
   490 testmath("Math.sqrt", "1", 1)
   491 testmath("Math.sqrt", "2", Math.SQRT2)
   492 testmath("Math.sqrt", "0.5", Math.SQRT1_2)
   493 testmath("Math.sqrt", "4", 2)
   494 testmath("Math.sqrt", "9", 3)
   495 testmath("Math.sqrt", "16", 4)
   496 testmath("Math.sqrt", "25", 5)
   497 testmath("Math.sqrt", "36", 6)
   498 testmath("Math.sqrt", "49", 7)
   499 testmath("Math.sqrt", "64", 8)
   500 testmath("Math.sqrt", "256", 16)
   501 testmath("Math.sqrt", "10000", 100)
   502 testmath("Math.sqrt", "65536", 256)
   503 testmath("Math.sqrt", "0.09", 0.3)
   504 testmath("Math.sqrt", "0.01", 0.1)
   505 testmath("Math.sqrt", "0.00000001", 0.0001)
   507 testmath("Math.tan", "void 0", Number.NaN)
   508 testmath("Math.tan", "null", 0)
   509 testmath("Math.tan", "false", 0)
   510 testmath("Math.tan", "Number.NaN", Number.NaN)
   511 testmath("Math.tan", "0", 0)
   512 testmath("Math.tan", "-0", -0)
   513 testmath("Math.tan", "Number.POSITIVE_INFINITY", Number.NaN)
   514 testmath("Math.tan", "Number.NEGATIVE_INFINITY", Number.NaN)
   515 testmath("Math.tan", "Math.PI/4", 1)
   516 testmath("Math.tan", "3*Math.PI/4", -1)
   517 testmath("Math.tan", "Math.PI", -0)
   518 testmath("Math.tan", "5*Math.PI/4", 1)
   519 testmath("Math.tan", "7*Math.PI/4", -1)
   520 testmath("Infinity/Math.tan", "-0", -Infinity)

mercurial