Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_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: If B = 10xxxxxx or B = 11111xxx, throw URIError
6 es5id: 15.1.3.2_A1.3_T2
7 es6id: 18.2.6.3
8 esid: sec-decodeuricomponent-encodeduricomponent
9 description: Complex tests. B = 11111xxx -> B in [0xF8 - 0xFF]
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 = 0xF8; index <= 0xFF; index++) {
19 count++;
20 var hex = decimalToPercentHexString(index);
21 try {
22 decodeURIComponent(hex);
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 $ERROR('#' + hexO + '-' + hexP + ' ');
34 }
35 else {
36 var hexP = decimalToHexString(indexP);
37 $ERROR('#' + 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 $ERROR('#' + hexO + '-' + hexP + ' ');
51 } else {
52 var hexP = decimalToHexString(indexP);
53 $ERROR('#' + hexP + ' ');
54 }
55 $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
56 }