tor-browser

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

S15.8.2.14_A1.js (740B)


      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: |
      6    Math.random() returns a number value with positive sign, greater than or
      7    equal to 0 but less than 1
      8 es5id: 15.8.2.14_A1
      9 description: >
     10    Checking if Math.random() is a number between 0 and 1, calling
     11    Math.random() 100 times
     12 ---*/
     13 
     14 // CHECK#1
     15 for (var i = 0; i < 100; i++)
     16 {
     17  var val = Math.random();
     18 
     19  assert.sameValue(
     20    typeof val, 'number', 'should not produce a non-numeric value: ' + val
     21  );
     22  assert.notSameValue(val, NaN, 'should not produce NaN');
     23 
     24  if (val < 0 || val >= 1)
     25  {
     26    throw new Test262Error("#1: Math.random() = " + val);
     27  }
     28 }
     29 
     30 reportCompare(0, 0);