js/src/tests/test262/ch07/7.4/S7.4_A6.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 // Copyright 2009 the Sputnik authors.  All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * If multi line comments csn not nest, they can contain any Unicode character
     6  *
     7  * @path ch07/7.4/S7.4_A6.js
     8  * @description "var"+ yy+ "xx = 1", insert instead of yy all Unicode characters
     9  */
    11 //CHECK
    12 var errorCount = 0;
    13 var count = 0;
    14 for (var indexI = 0; indexI <= 65535; indexI++) {
    15   try {
    16     var xx = 0;
    17     eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/");
    18     var hex = decimalToHexString(indexI);
    19     if (xx !== 0) {
    20       $ERROR('#' + hex + ' ');
    21       errorCount++;
    22     }
    23   } catch (e){
    24     $ERROR('#' + hex + ' ');
    25     errorCount++;
    26   }
    27   count++;
    28 }
    30 if (errorCount > 0) {
    31   $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count);
    32 }
    34 function decimalToHexString(n) {
    35   n = Number(n);
    36   var h = "";
    37   for (var i = 3; i >= 0; i--) {
    38     if (n >= Math.pow(16, i)) {
    39       var t = Math.floor(n / Math.pow(16, i));
    40       n -= t * Math.pow(16, i);
    41       if ( t >= 10 ) {
    42         if ( t == 10 ) { h += "A"; }
    43         if ( t == 11 ) { h += "B"; }
    44         if ( t == 12 ) { h += "C"; }
    45         if ( t == 13 ) { h += "D"; }
    46         if ( t == 14 ) { h += "E"; }
    47         if ( t == 15 ) { h += "F"; }
    48       } else {
    49         h += String(t);
    50       }
    51     } else {
    52       h += "0";
    53     }
    54   }
    55   return h;
    56 }

mercurial