test262/test/built-ins/decodeURI/S15.1.3.1_A2.1_T1.js
André Bargull 94f6003d11 Optimize decodeURI/encodeURI tests (#987)
* Move decimalToHexString into harness instead of duplicating it in multiple files

* Optimize decimalToHexString and support numbers greater than 65535

* Replace alternative decimalToHexString function with include for decimalToHexString.js

* Add decimalToHex2String to return the string representation of a two-digit hex-number

* Replace decimalToHex2String with decimalToPercentHexString to return the percent hex-encoded string of a two-digit hex-number

* Replace two String.fromCharCode calls with a single call

* Further reduce string concatentations in decodeURI[Component] tests

* Remove unnecessary Test262Error error handling in catch-clauses

* Remove try/catch wrappings in decodeURI/encodeURI tests
2017-04-18 16:31:31 -04:00

34 lines
819 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
es5id: 15.1.3.1_A2.1_T1
description: Complex tests
includes: [decimalToHexString.js]
---*/
//CHECK
var errorCount = 0;
var count = 0;
for (var indexI = 0; indexI <= 65535; indexI++) {
if (indexI !== 0x25) {
var hex = decimalToHexString(indexI);
try {
var str = String.fromCharCode(indexI);
if (decodeURI(str) !== str) {
$ERROR('#' + hex + ' ');
errorCount++;
}
} catch (e){
$ERROR('#' + hex + ' ');
errorCount++;
}
count++;
}
}
if (errorCount > 0) {
$ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count);
}