Throw distinctive errors for different failures

Prior to this patch, two distinct failure cases would produce the same
generic error message. Refactor the test logic to report the specific
condition which trigger failure.
This commit is contained in:
Mike Pennisi 2021-09-01 17:33:23 -04:00 committed by Rick Waldron
parent c324e5c620
commit 47ab262658
3 changed files with 15 additions and 12 deletions

View File

@ -12,11 +12,12 @@ for (var indexI = 0; indexI <= 65535; indexI++) {
if (indexI !== 0x25) {
try {
var str = String.fromCharCode(indexI);
if (decodeURI(str) !== str) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
}
var differs = decodeURI(str) !== str;
} catch (e) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
throw new Test262Error('#' + decimalToHexString(indexI) + ' throws');
}
if (differs) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' differs');
}
}
}

View File

@ -12,11 +12,12 @@ for (var indexI = 0; indexI <= 65535; indexI++) {
if (indexI !== 0x25) {
try {
var str = String.fromCharCode(indexI);
if (decodeURIComponent(str) !== str) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
}
var differs = decodeURIComponent(str) !== str;
} catch (e) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
throw new Test262Error('#' + decimalToHexString(indexI) + ' throws');
}
if (differs) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' differs');
}
}
}

View File

@ -14,10 +14,11 @@ for (var indexI = 0; indexI <= 65535; indexI++) {
try {
var xx = 0;
eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/");
if (xx !== 0) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
}
var differs = xx !== 0;
} catch (e){
throw new Test262Error('#' + decimalToHexString(indexI) + ' ');
throw new Test262Error('#' + decimalToHexString(indexI) + ' throws');
}
if (differs) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' differs');
}
}