Debian Codegraph @

js/src/tests/test262/built-ins/decodeURIComponent/S15.1.3.2_A1.2_T1.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 If B = string.charAt(k+1) + string.charAt(k+2) do not represent
7 hexadecimal digits, throw URIError
8 esid: sec-decodeuricomponent-encodeduricomponent
9 description: Complex tests
10 ---*/
11
12 //CHECK
13 var result = true;
14 var interval = [
15 [0x00, 0x2F],
16 [0x3A, 0x40],
17 [0x47, 0x60],
18 [0x67, 0xFFFF]
19 ];
20 for (var indexI = 0; indexI < interval.length; indexI++) {
21 for (var indexJ = interval[indexI][0]; indexJ <= interval[indexI][1]; indexJ++) {
22 try {
23 decodeURIComponent("%" + String.fromCharCode(indexJ) + "1");
24 result = false;
25 } catch (e) {
26 if ((e instanceof URIError) !== true) {
27 result = false;
28 }
29 }
30 }
31 }
32
33 if (result !== true) {
34 throw new Test262Error('#1: If string.charAt(k+1) does not represent hexadecimal digits, throw URIError');
35 }
36
37 reportCompare(0, 0);