Debian Codegraph @

js/src/tests/test262/built-ins/decodeURIComponent/S15.1.3.2_A1.5_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: If B = 1110xxxx (n = 3) and (k + 2) + 6 >= length, throw URIError
6 esid: sec-decodeuricomponent-encodeduricomponent
7 description: Complex tests. B = [0xE0 - 0xEF]
8 includes: [decimalToHexString.js]
9 ---*/
10
11 var errorCount = 0;
12 var count = 0;
13 var indexP;
14 var indexO = 0;
15
16 for (var index = 0xE0; index <= 0xEF; index++) {
17 count++;
18 var str = "";
19 var result = true;
20 for (var len = 0; len < 6; len++) {
21 var hex = decimalToPercentHexString(index);
22 try {
23 decodeURIComponent(hex + str);
24 } catch (e) {
25 if ((e instanceof URIError) === true) continue;
26 }
27 result = false;
28 str = str + "1";
29 }
30 if (result !== true) {
31 if (indexO === 0) {
32 indexO = index;
33 } else {
34 if ((index - indexP) !== 1) {
35 if ((indexP - indexO) !== 0) {
36 var hexP = decimalToHexString(indexP);
37 var hexO = decimalToHexString(indexO);
38 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
39 }
40 else {
41 var hexP = decimalToHexString(indexP);
42 throw new Test262Error('#' + hexP + ' ');
43 }
44 indexO = index;
45 }
46 }
47 indexP = index;
48 errorCount++;
49 }
50 }
51
52 if (errorCount > 0) {
53 if ((indexP - indexO) !== 0) {
54 var hexP = decimalToHexString(indexP);
55 var hexO = decimalToHexString(indexO);
56 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
57 } else {
58 var hexP = decimalToHexString(indexP);
59 throw new Test262Error('#' + hexP + ' ');
60 }
61 throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
62 }
63
64 reportCompare(0, 0);