tor-browser

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

S15.1.2.2_A7.2_T1.js (1351B)


      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    Compute the mathematical integer value
      7    that is represented by Z in radix-R notation, using the
      8    letters A-Z and a-z for digits with values 10 through 35.
      9    Compute the number value for Result(16)
     10 esid: sec-parseint-string-radix
     11 description: Complex test. Check algorithm
     12 ---*/
     13 
     14 //CHECK#
     15 var R_digit1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
     16 var R_digit2 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
     17 for (var i = 2; i <= 36; i++) {
     18  for (var j = 0; j < 10; j++) {
     19    var str = "";
     20    var num = 0;
     21    var pow = 1;
     22    var k0 = Math.max(2, i - j);
     23    for (var k = k0; k <= i; k++) {
     24      if (k % 2 === 0) {
     25        str = str + R_digit1[k - 2];
     26      } else {
     27        str = str + R_digit2[k - 2];
     28      }
     29      num = num + (i + (k0 - k) - 1) * pow;
     30      pow = pow * i;
     31    }
     32    assert.sameValue(parseInt(str, i), num, 'parseInt("str + R_digit2[k - 2], i) must return the value of num');
     33  }
     34 }
     35 
     36 reportCompare(0, 0);