S15.1.3.2_A2.5_T1.js (2507B)
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 B1 = 11110xxx ([0xF0 - 0x0F4]), B2, B3, B4 = 10xxxxxxx ([0x80 - 7 0xBF]), without [B1, B2] = [0xF0, 0x80 - 0x9F], [0xF4, 0x90 - 0xBF], 8 return UTF8(B1, B2, B3, B4) 9 esid: sec-decodeuricomponent-encodeduricomponent 10 description: Complex tests, use RFC 3629 11 includes: [decimalToHexString.js] 12 ---*/ 13 14 var errorCount = 0; 15 var count = 0; 16 var indexP; 17 var indexO = 0; 18 19 for (var indexB1 = 0xF0; indexB1 <= 0xF4; indexB1++) { 20 var hexB1 = decimalToPercentHexString(indexB1); 21 for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { 22 if ((indexB1 === 0xF0) && (indexB2 <= 0x9F)) continue; 23 if ((indexB1 === 0xF4) && (indexB2 >= 0x90)) continue; 24 var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); 25 for (var indexB3 = 0x80; indexB3 <= 0xBF; indexB3++) { 26 var hexB1_B2_B3 = hexB1_B2 + decimalToPercentHexString(indexB3); 27 for (var indexB4 = 0x80; indexB4 <= 0xBF; indexB4++) { 28 var hexB1_B2_B3_B4 = hexB1_B2_B3 + decimalToPercentHexString(indexB4); 29 count++; 30 var index = (indexB1 & 0x07) * 0x40000 + (indexB2 & 0x3F) * 0x1000 + (indexB3 & 0x3F) * 0x40 + (indexB4 & 0x3F); 31 var L = ((index - 0x10000) & 0x03FF) + 0xDC00; 32 var H = (((index - 0x10000) >> 10) & 0x03FF) + 0xD800; 33 if (decodeURIComponent(hexB1_B2_B3_B4) === String.fromCharCode(H, L)) continue; 34 35 if (indexO === 0) { 36 indexO = index; 37 } else { 38 if ((index - indexP) !== 1) { 39 if ((indexP - indexO) !== 0) { 40 var hexP = decimalToHexString(indexP); 41 var hexO = decimalToHexString(indexO); 42 throw new Test262Error('#' + hexO + '-' + hexP + ' '); 43 } 44 else { 45 var hexP = decimalToHexString(indexP); 46 throw new Test262Error('#' + hexP + ' '); 47 } 48 indexO = index; 49 } 50 } 51 indexP = index; 52 errorCount++; 53 } 54 } 55 } 56 } 57 58 if (errorCount > 0) { 59 if ((indexP - indexO) !== 0) { 60 var hexP = decimalToHexString(indexP); 61 var hexO = decimalToHexString(indexO); 62 throw new Test262Error('#' + hexO + '-' + hexP + ' '); 63 } else { 64 var hexP = decimalToHexString(indexP); 65 throw new Test262Error('#' + hexP + ' '); 66 } 67 throw new Test262Error('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); 68 } 69 70 reportCompare(0, 0);