Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_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 string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError
6 es5id: 15.1.3.4_A1.1_T2
7 es6id: 18.2.6.5
8 esid: sec-encodeuricomponent-uricomponent
9 description: Complex tests
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 = 0xDC00; index <= 0xDFFF; index++) {
19 count++;
20 var hex = decimalToHexString(index);
21 try {
22 encodeURIComponent(String.fromCharCode(index, 0x0041));
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 }