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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch07/7.4/S7.4_A6.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +// Copyright 2009 the Sputnik authors.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * If multi line comments csn not nest, they can contain any Unicode character
     1.9 + *
    1.10 + * @path ch07/7.4/S7.4_A6.js
    1.11 + * @description "var"+ yy+ "xx = 1", insert instead of yy all Unicode characters
    1.12 + */
    1.13 +
    1.14 +//CHECK
    1.15 +var errorCount = 0;
    1.16 +var count = 0;
    1.17 +for (var indexI = 0; indexI <= 65535; indexI++) {
    1.18 +  try {
    1.19 +    var xx = 0;
    1.20 +    eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/");
    1.21 +    var hex = decimalToHexString(indexI);
    1.22 +    if (xx !== 0) {
    1.23 +      $ERROR('#' + hex + ' ');
    1.24 +      errorCount++;
    1.25 +    }
    1.26 +  } catch (e){
    1.27 +    $ERROR('#' + hex + ' ');
    1.28 +    errorCount++;
    1.29 +  }
    1.30 +  count++;
    1.31 +}
    1.32 +
    1.33 +if (errorCount > 0) {
    1.34 +  $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count);
    1.35 +}
    1.36 +
    1.37 +function decimalToHexString(n) {
    1.38 +  n = Number(n);
    1.39 +  var h = "";
    1.40 +  for (var i = 3; i >= 0; i--) {
    1.41 +    if (n >= Math.pow(16, i)) {
    1.42 +      var t = Math.floor(n / Math.pow(16, i));
    1.43 +      n -= t * Math.pow(16, i);
    1.44 +      if ( t >= 10 ) {
    1.45 +        if ( t == 10 ) { h += "A"; }
    1.46 +        if ( t == 11 ) { h += "B"; }
    1.47 +        if ( t == 12 ) { h += "C"; }
    1.48 +        if ( t == 13 ) { h += "D"; }
    1.49 +        if ( t == 14 ) { h += "E"; }
    1.50 +        if ( t == 15 ) { h += "F"; }
    1.51 +      } else {
    1.52 +        h += String(t);
    1.53 +      }
    1.54 +    } else {
    1.55 +      h += "0";
    1.56 +    }
    1.57 +  }
    1.58 +  return h;
    1.59 +}
    1.60 +

mercurial