mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 21:45:04 +02:00
avoid unnecessary calls to decimalToHexString() (#3170)
This commit is contained in:
parent
836111dc3c
commit
603b10dbfa
@ -10,14 +10,13 @@ includes: [decimalToHexString.js]
|
|||||||
|
|
||||||
for (var indexI = 0; indexI <= 65535; indexI++) {
|
for (var indexI = 0; indexI <= 65535; indexI++) {
|
||||||
if (indexI !== 0x25) {
|
if (indexI !== 0x25) {
|
||||||
var hex = decimalToHexString(indexI);
|
|
||||||
try {
|
try {
|
||||||
var str = String.fromCharCode(indexI);
|
var str = String.fromCharCode(indexI);
|
||||||
if (decodeURI(str) !== str) {
|
if (decodeURI(str) !== str) {
|
||||||
throw new Test262Error('#' + hex + ' ');
|
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Test262Error('#' + hex + ' ');
|
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,13 @@ includes: [decimalToHexString.js]
|
|||||||
|
|
||||||
for (var indexI = 0; indexI <= 65535; indexI++) {
|
for (var indexI = 0; indexI <= 65535; indexI++) {
|
||||||
if (indexI !== 0x25) {
|
if (indexI !== 0x25) {
|
||||||
var hex = decimalToHexString(indexI);
|
|
||||||
try {
|
try {
|
||||||
var str = String.fromCharCode(indexI);
|
var str = String.fromCharCode(indexI);
|
||||||
if (decodeURIComponent(str) !== str) {
|
if (decodeURIComponent(str) !== str) {
|
||||||
throw new Test262Error('#' + hex + ' ');
|
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Test262Error('#' + hex + ' ');
|
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURI(String.fromCharCode(index));
|
encodeURI(String.fromCharCode(index));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -15,7 +15,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURI(String.fromCharCode(index, 0x0041));
|
encodeURI(String.fromCharCode(index, 0x0041));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -17,7 +17,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURI(String.fromCharCode(index));
|
encodeURI(String.fromCharCode(index));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -17,7 +17,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURI(String.fromCharCode(0x0041, index));
|
encodeURI(String.fromCharCode(0x0041, index));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -22,7 +22,6 @@ for (var index = 0xD800; index <= 0xDBFF; index++) {
|
|||||||
count++;
|
count++;
|
||||||
var res = true;
|
var res = true;
|
||||||
for (var indexC = 0; indexC < chars.length; indexC++) {
|
for (var indexC = 0; indexC < chars.length; indexC++) {
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURI(String.fromCharCode(index, chars[indexC]));
|
encodeURI(String.fromCharCode(index, chars[indexC]));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -15,7 +15,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURIComponent(String.fromCharCode(index));
|
encodeURIComponent(String.fromCharCode(index));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -15,7 +15,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
for (var index = 0xDC00; index <= 0xDFFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURIComponent(String.fromCharCode(index, 0x0041));
|
encodeURIComponent(String.fromCharCode(index, 0x0041));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -17,7 +17,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURIComponent(String.fromCharCode(index));
|
encodeURIComponent(String.fromCharCode(index));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -17,7 +17,6 @@ var indexO = 0;
|
|||||||
|
|
||||||
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
for (var index = 0xD800; index <= 0xDBFF; index++) {
|
||||||
count++;
|
count++;
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURIComponent(String.fromCharCode(0x0041, index));
|
encodeURIComponent(String.fromCharCode(0x0041, index));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -22,7 +22,6 @@ for (var index = 0xD800; index <= 0xDBFF; index++) {
|
|||||||
count++;
|
count++;
|
||||||
var res = true;
|
var res = true;
|
||||||
for (var indexC = 0; indexC < chars.length; indexC++) {
|
for (var indexC = 0; indexC < chars.length; indexC++) {
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
try {
|
try {
|
||||||
encodeURIComponent(String.fromCharCode(index, chars[indexC]));
|
encodeURIComponent(String.fromCharCode(index, chars[indexC]));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -19,7 +19,6 @@ var indexP;
|
|||||||
var indexO = 0;
|
var indexO = 0;
|
||||||
for (var index = 0; index <= 65535; index++) {
|
for (var index = 0; index <= 65535; index++) {
|
||||||
if ((index < 0x0030) || (index > 0x0039)) {
|
if ((index < 0x0030) || (index > 0x0039)) {
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
if (parseFloat("0.1e1" + String.fromCharCode(index)) !== 1) {
|
if (parseFloat("0.1e1" + String.fromCharCode(index)) !== 1) {
|
||||||
if (indexO === 0) {
|
if (indexO === 0) {
|
||||||
indexO = index;
|
indexO = index;
|
||||||
|
@ -21,7 +21,6 @@ for (var index = 0; index <= 65535; index++) {
|
|||||||
if ((index < 0x0030) || (index > 0x0039) &&
|
if ((index < 0x0030) || (index > 0x0039) &&
|
||||||
(index < 0x0041) || (index > 0x005A) &&
|
(index < 0x0041) || (index > 0x005A) &&
|
||||||
(index < 0x0061) || (index > 0x007A)) {
|
(index < 0x0061) || (index > 0x007A)) {
|
||||||
var hex = decimalToHexString(index);
|
|
||||||
if (parseInt("1Z" + String.fromCharCode(index), 36) !== 71) {
|
if (parseInt("1Z" + String.fromCharCode(index), 36) !== 71) {
|
||||||
if (indexO === 0) {
|
if (indexO === 0) {
|
||||||
indexO = index;
|
indexO = index;
|
||||||
|
@ -7,41 +7,17 @@ info: |
|
|||||||
character
|
character
|
||||||
es5id: 7.4_A6
|
es5id: 7.4_A6
|
||||||
description: "\"var\"+ yy+ \"xx = 1\", insert instead of yy all Unicode characters"
|
description: "\"var\"+ yy+ \"xx = 1\", insert instead of yy all Unicode characters"
|
||||||
|
includes: [decimalToHexString.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
for (var indexI = 0; indexI <= 65535; indexI++) {
|
for (var indexI = 0; indexI <= 65535; indexI++) {
|
||||||
try {
|
try {
|
||||||
var xx = 0;
|
var xx = 0;
|
||||||
eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/");
|
eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/");
|
||||||
var hex = decimalToHexString(indexI);
|
|
||||||
if (xx !== 0) {
|
if (xx !== 0) {
|
||||||
throw new Test262Error('#' + hex + ' ');
|
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
|
||||||
}
|
}
|
||||||
} catch (e){
|
} catch (e){
|
||||||
throw new Test262Error('#' + hex + ' ');
|
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function decimalToHexString(n) {
|
|
||||||
n = Number(n);
|
|
||||||
var h = "";
|
|
||||||
for (var i = 3; i >= 0; i--) {
|
|
||||||
if (n >= Math.pow(16, i)) {
|
|
||||||
var t = Math.floor(n / Math.pow(16, i));
|
|
||||||
n -= t * Math.pow(16, i);
|
|
||||||
if ( t >= 10 ) {
|
|
||||||
if ( t == 10 ) { h += "A"; }
|
|
||||||
if ( t == 11 ) { h += "B"; }
|
|
||||||
if ( t == 12 ) { h += "C"; }
|
|
||||||
if ( t == 13 ) { h += "D"; }
|
|
||||||
if ( t == 14 ) { h += "E"; }
|
|
||||||
if ( t == 15 ) { h += "F"; }
|
|
||||||
} else {
|
|
||||||
h += String(t);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
h += "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user