Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/decodeURIComponent/S15.1.3.2_A1.4_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 = 110xxxxx (n = 2) and (k + 2) + 3 >= length, throw URIError
6 es5id: 15.1.3.2_A1.4_T1
7 es6id: 18.2.6.3
8 esid: sec-decodeuricomponent-encodeduricomponent
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 str = "";
21 var result = true;
22 for (var len = 0; len < 3; len++) {
23 var hex = decimalToPercentHexString(index);
24 try {
25 decodeURIComponent(hex + str);
26 } catch (e) {
27 if ((e instanceof URIError) === true) continue;
28 }
29 result = false;
30 str = str + "1";
31 }
32 if (result !== true) {
33 if (indexO === 0) {
34 indexO = index;
35 } else {
36 if ((index - indexP) !== 1) {
37 if ((indexP - indexO) !== 0) {
38 var hexP = decimalToHexString(indexP);
39 var hexO = decimalToHexString(indexO);
40 $ERROR('#' + hexO + '-' + hexP + ' ');
41 }
42 else {
43 var hexP = decimalToHexString(indexP);
44 $ERROR('#' + hexP + ' ');
45 }
46 indexO = index;
47 }
48 }
49 indexP = index;
50 errorCount++;
51 }
52 }
53
54 if (errorCount > 0) {
55 if ((indexP - indexO) !== 0) {
56 var hexP = decimalToHexString(indexP);
57 var hexO = decimalToHexString(indexO);
58 $ERROR('#' + hexO + '-' + hexP + ' ');
59 } else {
60 var hexP = decimalToHexString(indexP);
61 $ERROR('#' + hexP + ' ');
62 }
63 $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
64 }