~ubuntu-branches/ubuntu/trusty/mozjs24/trusty-proposed

« back to all changes in this revision

Viewing changes to js/src/tests/test262/ch07/7.4/S7.4_A6.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * 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
 */
 
10
 
 
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
}
 
29
 
 
30
if (errorCount > 0) {
 
31
  $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count);
 
32
}
 
33
 
 
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
}
 
57