Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_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 = 11110xxx (n = 4) and string.charAt(k + 3),
7 string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError
8 es5id: 15.1.3.2_A1.9_T1
9 es6id: 18.2.6.3
10 esid: sec-decodeuricomponent-encodeduricomponent
11 description: >
12 Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 3) not equal "%"
13 includes: [decimalToHexString.js]
14 ---*/
15
16 var errorCount = 0;
17 var count = 0;
18 var indexP;
19 var indexO = 0;
20
21 for (var index = 0xF0; index <= 0xF7; index++) {
22 count++;
23 var hex = decimalToPercentHexString(index);
24 try {
25 decodeURIComponent(hex + "111%A0%A0");
26 } catch (e) {
27 if ((e instanceof URIError) === true) continue;
28 }
29 if (indexO === 0) {
30 indexO = index;
31 } else {
32 if ((index - indexP) !== 1) {
33 if ((indexP - indexO) !== 0) {
34 var hexP = decimalToHexString(indexP);
35 var hexO = decimalToHexString(indexO);
36 $ERROR('#' + hexO + '-' + hexP + ' ');
37 }
38 else {
39 var hexP = decimalToHexString(indexP);
40 $ERROR('#' + hexP + ' ');
41 }
42 indexO = index;
43 }
44 }
45 indexP = index;
46 errorCount++;
47 }
48
49 if (errorCount > 0) {
50 if ((indexP - indexO) !== 0) {
51 var hexP = decimalToHexString(indexP);
52 var hexO = decimalToHexString(indexO);
53 $ERROR('#' + hexO + '-' + hexP + ' ');
54 } else {
55 var hexP = decimalToHexString(indexP);
56 $ERROR('#' + hexP + ' ');
57 }
58 $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
59 }