Debian Codegraph @

js/src/tests/test262/built-ins/decodeURI/S15.1.3.1_A2.3_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 B1 = 110xxxxx ([0xC0 - 0xDF]), B2 = 10xxxxxx ([0x80 - 0xBF), without
7 B1 = [0xC0, 0xC1], return UTF8(B1, B2)
8 esid: sec-decodeuri-encodeduri
9 description: Complex tests, use RFC 3629
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 indexB1 = 0xC2; indexB1 <= 0xDF; indexB1++) {
19 var hexB1 = decimalToPercentHexString(indexB1);
20 for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) {
21 count++;
22 var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2);
23 var index = (indexB1 & 0x1F) * 0x40 + (indexB2 & 0x3F);
24 if (decodeURI(hexB1_B2) === String.fromCharCode(index)) 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
47 if (errorCount > 0) {
48 if ((indexP - indexO) !== 0) {
49 var hexP = decimalToHexString(indexP);
50 var hexO = decimalToHexString(indexO);
51 throw new Test262Error('#' + hexO + '-' + hexP + ' ');
52 } else {
53 var hexP = decimalToHexString(indexP);
54 throw new Test262Error('#' + hexP + ' ');
55 }
56 throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
57 }
58
59 reportCompare(0, 0);