michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * If multi line comments csn not nest, they can contain any Unicode character michael@0: * michael@0: * @path ch07/7.4/S7.4_A6.js michael@0: * @description "var"+ yy+ "xx = 1", insert instead of yy all Unicode characters michael@0: */ michael@0: michael@0: //CHECK michael@0: var errorCount = 0; michael@0: var count = 0; michael@0: for (var indexI = 0; indexI <= 65535; indexI++) { michael@0: try { michael@0: var xx = 0; michael@0: eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/"); michael@0: var hex = decimalToHexString(indexI); michael@0: if (xx !== 0) { michael@0: $ERROR('#' + hex + ' '); michael@0: errorCount++; michael@0: } michael@0: } catch (e){ michael@0: $ERROR('#' + hex + ' '); michael@0: errorCount++; michael@0: } michael@0: count++; michael@0: } michael@0: michael@0: if (errorCount > 0) { michael@0: $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count); michael@0: } michael@0: michael@0: function decimalToHexString(n) { michael@0: n = Number(n); michael@0: var h = ""; michael@0: for (var i = 3; i >= 0; i--) { michael@0: if (n >= Math.pow(16, i)) { michael@0: var t = Math.floor(n / Math.pow(16, i)); michael@0: n -= t * Math.pow(16, i); michael@0: if ( t >= 10 ) { michael@0: if ( t == 10 ) { h += "A"; } michael@0: if ( t == 11 ) { h += "B"; } michael@0: if ( t == 12 ) { h += "C"; } michael@0: if ( t == 13 ) { h += "D"; } michael@0: if ( t == 14 ) { h += "E"; } michael@0: if ( t == 15 ) { h += "F"; } michael@0: } else { michael@0: h += String(t); michael@0: } michael@0: } else { michael@0: h += "0"; michael@0: } michael@0: } michael@0: return h; michael@0: } michael@0: