Debian Codegraph @

js/src/tests/test262/built-ins/decodeURI/S15.1.3.1_A1.14_T2.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 = 1110xxxx (n = 3) and C != 10xxxxxx (C - first of octets after B),
7 throw URIError
8 esid: sec-decodeuri-encodeduri
9 description: Complex tests. B = [0xE0 - 0xEF], C = [0x00, 0x7F]
10 includes: [decimalToHexString.js]
11 ---*/
12
13 var errorCount = 0;
14 var count = 0;
15 var indexP;
16 var indexO = 0;
17
18 for (var indexB = 0xE0; indexB <= 0xEF; indexB++) {
19 count++;
20 var hexB = decimalToPercentHexString(indexB);
21 var result = true;
22 for (var indexC = 0x00; indexC <= 0x7F; indexC++) {
23 var hexC = decimalToPercentHexString(indexC);
24 try {
25 decodeURI(hexB + "%A0" + hexC);
26 } catch (e) {
27 if ((e instanceof URIError) === true) continue;
28 }
29 result = false;
30 }
31 if (result !== true) {
32 if (indexO === 0) {
33 indexO = indexB;
34 } else {
35 if ((indexB - indexP) !== 1) {
36 if ((indexP - indexO) !== 0) {
37 var hexP = decimalToHexString(indexP);
38 var hexO = decimalToHexString(indexO);
39 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
40 }
41 else {
42 var hexP = decimalToHexString(indexP);
43 throw new Test262Error('#' + hexP + ' ');
44 }
45 indexO = indexB;
46 }
47 }
48 indexP = indexB;
49 errorCount++;
50 }
51 }
52
53 if (errorCount > 0) {
54 if ((indexP - indexO) !== 0) {
55 var hexP = decimalToHexString(indexP);
56 var hexO = decimalToHexString(indexO);
57 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
58 } else {
59 var hexP = decimalToHexString(indexP);
60 throw new Test262Error('#' + hexP + ' ');
61 }
62 throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
63 }
64
65 reportCompare(0, 0);