tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

S15.8.2.11_A2.js (1344B)


      1 // Copyright 2009 the Sputnik authors.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 info: If any value is NaN, the result of Math.max is NaN
      6 es5id: 15.8.2.11_A2
      7 description: >
      8    The script tests Math.max giving 1, 2 and 3 arguments to the
      9    function where at least one of the arguments is NaN
     10 ---*/
     11 
     12 assert.sameValue(Math.max(NaN), NaN, "NaN");
     13 
     14 // CHECK#2
     15 var vals = new Array();
     16 vals[0] = -Infinity;
     17 vals[1] = -0.000000000000001;
     18 vals[2] = -0;
     19 vals[3] = +0
     20 vals[4] = 0.000000000000001;
     21 vals[5] = +Infinity;
     22 vals[6] = NaN;
     23 var valnum = 7;
     24 
     25 var args = new Array();
     26 for (var i = 0; i <= 1; i++)
     27 {
     28  args[i] = NaN;
     29  for (var j = 0; j < valnum; j++)
     30  {
     31    args[1 - i] = vals[j];
     32    assert.sameValue(
     33      Math.max(args[0], args[1]),
     34      NaN,
     35      "max(" + args[0] + ", " + args[1] + ")"
     36    );
     37  }
     38 }
     39 
     40 // CHECK #3
     41 var k = 1;
     42 var l = 2;
     43 for (var i = 0; i <= 2; i++)
     44 {
     45  args[i] = NaN;
     46  if (i === 1)
     47  {
     48    k = 0;
     49  } else if (i === 2)
     50  {
     51    l = 1;
     52  }
     53  for (var j = 0; j < valnum; j++)
     54  {
     55    for (var jj = 0; jj < valnum; jj++)
     56    {
     57      args[k] = vals[j];
     58      args[l] = vals[jj];
     59      assert.sameValue(
     60        Math.max(args[0], args[1], args[2]),
     61        NaN,
     62        "max(" + args[0] + ", " + args[1] + ", " + args[2] + ")"
     63      );
     64    }
     65  }
     66 }
     67 
     68 reportCompare(0, 0);