| 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 B1 = 0xxxxxxxx ([0x00 - 0x7F]), return B1 |
| 6 |
es5id: 15.1.3.2_A2.2_T1 |
| 7 |
es6id: 18.2.6.3 |
| 8 |
esid: sec-decodeuricomponent-encodeduricomponent |
| 9 |
description: Complex tests, use RFC 3629 |
| 10 |
includes: [decimalToHexString.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
var errorCount = 0; |
| 14 |
var count = 0; |
| 15 |
var indexP; |
| 16 |
var indexO = 0; |
| 17 |
for (var indexB1 = 0x00; indexB1 <= 0x7F; indexB1++) { |
| 18 |
count++; |
| 19 |
var hexB1 = decimalToPercentHexString(indexB1); |
| 20 |
var index = indexB1; |
| 21 |
var hex = String.fromCharCode(index); |
| 22 |
if (decodeURIComponent(hexB1) === hex) continue; |
| 23 |
|
| 24 |
if (indexO === 0) { |
| 25 |
indexO = index; |
| 26 |
} else { |
| 27 |
if ((index - indexP) !== 1) { |
| 28 |
if ((indexP - indexO) !== 0) { |
| 29 |
var hexP = decimalToHexString(indexP); |
| 30 |
var hexO = decimalToHexString(indexO); |
| 31 |
$ERROR('#' + hexO + '-' + hexP + ' '); |
| 32 |
} |
| 33 |
else { |
| 34 |
var hexP = decimalToHexString(indexP); |
| 35 |
$ERROR('#' + hexP + ' '); |
| 36 |
} |
| 37 |
indexO = index; |
| 38 |
} |
| 39 |
} |
| 40 |
indexP = index; |
| 41 |
errorCount++; |
| 42 |
} |
| 43 |
|
| 44 |
if (errorCount > 0) { |
| 45 |
if ((indexP - indexO) !== 0) { |
| 46 |
var hexP = decimalToHexString(indexP); |
| 47 |
var hexO = decimalToHexString(indexO); |
| 48 |
$ERROR('#' + hexO + '-' + hexP + ' '); |
| 49 |
} else { |
| 50 |
var hexP = decimalToHexString(indexP); |
| 51 |
$ERROR('#' + hexP + ' '); |
| 52 |
} |
| 53 |
$ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); |
| 54 |
} |