Debian Codegraph @

js/src/tests/test262/built-ins/decodeURI/S15.1.3.1_A1.7_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 = 110xxxxx (n = 2) and string.charAt(k + 3) not equal "%", throw
7 URIError
8 esid: sec-decodeuri-encodeduri
9 description: Complex tests. B = [0xC0 - 0xDF]
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 index = 0xC0; index <= 0xDF; index++) {
19 count++;
20 var hex = decimalToPercentHexString(index);
21 try {
22 decodeURI(hex + "111");
23 } catch (e) {
24 if ((e instanceof URIError) === true) continue;
25 }
26 if (indexO === 0) {
27 indexO = index;
28 } else {
29 if ((index - indexP) !== 1) {
30 if ((indexP - indexO) !== 0) {
31 var hexP = decimalToHexString(indexP);
32 var hexO = decimalToHexString(indexO);
33 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
34 }
35 else {
36 var hexP = decimalToHexString(indexP);
37 throw new Test262Error('#' + hexP + ' ');
38 }
39 indexO = index;
40 }
41 }
42 indexP = index;
43 errorCount++;
44 }
45
46 if (errorCount > 0) {
47 if ((indexP - indexO) !== 0) {
48 var hexP = decimalToHexString(indexP);
49 var hexO = decimalToHexString(indexO);
50 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
51 } else {
52 var hexP = decimalToHexString(indexP);
53 throw new Test262Error('#' + hexP + ' ');
54 }
55 throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
56 }
57
58 reportCompare(0, 0);