test262/test/built-ins/decodeURI/S15.1.3.1_A2.1_T1.js
Mike Pennisi 47ab262658 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.
2021-09-02 10:36:00 -04:00

24 lines
678 B
JavaScript

// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: If string.charAt(k) not equal "%", return this char
esid: sec-decodeuri-encodeduri
description: Complex tests
includes: [decimalToHexString.js]
---*/
for (var indexI = 0; indexI <= 65535; indexI++) {
if (indexI !== 0x25) {
try {
var str = String.fromCharCode(indexI);
var differs = decodeURI(str) !== str;
} catch (e) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' throws');
}
if (differs) {
throw new Test262Error('#' + decimalToHexString(indexI) + ' differs');
}
}
}