Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_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 string.charAt(k) in [0xD800 - 0xDBFF] and string.length = k + 1, throw
7 URIError
8 es5id: 15.1.3.4_A1.2_T1
9 es6id: 18.2.6.5
10 esid: sec-encodeuricomponent-uricomponent
11 description: Complex tests
12 includes: [decimalToHexString.js]
13 ---*/
14
15 var errorCount = 0;
16 var count = 0;
17 var indexP;
18 var indexO = 0;
19
20 for (var index = 0xD800; index <= 0xDBFF; index++) {
21 count++;
22 var hex = decimalToHexString(index);
23 try {
24 encodeURIComponent(String.fromCharCode(index));
25 } catch (e) {
26 if ((e instanceof URIError) === true) continue;
27 }
28 if (indexO === 0) {
29 indexO = index;
30 } else {
31 if ((index - indexP) !== 1) {
32 if ((indexP - indexO) !== 0) {
33 var hexP = decimalToHexString(indexP);
34 var hexO = decimalToHexString(indexO);
35 $ERROR('#' + hexO + '-' + hexP + ' ');
36 }
37 else {
38 var hexP = decimalToHexString(indexP);
39 $ERROR('#' + hexP + ' ');
40 }
41 indexO = index;
42 }
43 }
44 indexP = index;
45 errorCount++;
46 }
47
48 if (errorCount > 0) {
49 if ((indexP - indexO) !== 0) {
50 var hexP = decimalToHexString(indexP);
51 var hexO = decimalToHexString(indexO);
52 $ERROR('#' + hexO + '-' + hexP + ' ');
53 } else {
54 var hexP = decimalToHexString(indexP);
55 $ERROR('#' + hexP + ' ');
56 }
57 $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' ');
58 }