diff --git a/harness/decimalToHexString.js b/harness/decimalToHexString.js new file mode 100644 index 0000000000..36a2bb5b49 --- /dev/null +++ b/harness/decimalToHexString.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +function decimalToHexString(n) { + var hex = "0123456789ABCDEF"; + n >>>= 0; + var s = ""; + while (n) { + s = hex[n & 0xf] + s; + n >>>= 4; + } + while (s.length < 4) { + s = "0" + s; + } + return s; +} + +function decimalToPercentHexString(n) { + var hex = "0123456789ABCDEF"; + return "%" + hex[(n >> 4) & 0xf] + hex[n & 0xf]; +} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.13_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.13_T1.js index a1f9ec4868..d97fc87d9e 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.13_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.13_T1.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.13_T1 description: Complex tests. B = [0xC0 - 0xDF], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xC0; indexB <= 0xDF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%" + hexC.substring(2)); + decodeURI(hexB + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.13_T2.js b/test/built-ins/decodeURI/S15.1.3.1_A1.13_T2.js index f257b6b9e1..62767984b2 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.13_T2.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.13_T2.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.13_T2 description: Complex tests. B = [0xC0 - 0xDF], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xC0; indexB <= 0xDF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%" + hexC.substring(2)); + decodeURI(hexB + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T1.js index 8357cea7f0..e63fa0bcab 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T1.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.14_T1 description: Complex tests. B = [0xE0 - 0xEF], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0"); + decodeURI(hexB + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T2.js b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T2.js index 23c4d5f509..35b721e83e 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T2.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T2.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.14_T2 description: Complex tests. B = [0xE0 - 0xEF], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2)); + decodeURI(hexB + "%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T3.js b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T3.js index d69fdab9d9..c3c6e6c1fb 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T3.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T3.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.14_T3 description: Complex tests. B = [0xE0 - 0xEF], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0"); + decodeURI(hexB + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T4.js b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T4.js index 2946136d76..eca2066287 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.14_T4.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.14_T4.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.14_T4 description: Complex tests. B = [0xE0 - 0xEF], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2)); + decodeURI(hexB + "%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T1.js index ad1febe2f7..7eb031a2ef 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T1.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.15_T1 description: Complex tests. B = [0xF0 - 0x0F7], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0%A0"); + decodeURI(hexB + hexC + "%A0%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T2.js b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T2.js index 401a388206..ac8a83160f 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T2.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T2.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.15_T2 description: Complex tests. B = [0xF0 - 0x0F7], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2) + "%A0"); + decodeURI(hexB + "%A0" + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T3.js b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T3.js index 84ba141934..25e23d51e5 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T3.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T3.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.15_T3 description: Complex tests. B = [0xF0 - 0x0F7], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%A0%A0" + "%" + hexC.substring(2)); + decodeURI(hexB + "%A0%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T4.js b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T4.js index 839911bfef..83b84fe685 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T4.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T4.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.15_T4 description: Complex tests. B = [0xF0 - 0x0F7], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0%A0"); + decodeURI(hexB + hexC + "%A0%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T5.js b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T5.js index 11dc028433..caad3a8b45 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T5.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T5.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.15_T5 description: Complex tests. B = [0xF0 - 0x0F7], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2) + "%A0"); + decodeURI(hexB + "%A0" + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T6.js b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T6.js index 50eaff52c0..5fa20665c7 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.15_T6.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.15_T6.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.1_A1.15_T6 description: Complex tests. B = [0xF0 - 0x0F7], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURI("%" + hexB.substring(2) + "%A0%A0" + "%" + hexC.substring(2)); + decodeURI(hexB + "%A0%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.3_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.3_T1.js index 7125c02a75..636c05160e 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.3_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.3_T1.js @@ -5,6 +5,7 @@ info: If B = 10xxxxxx or B = 11111xxx, throw URIError es5id: 15.1.3.1_A1.3_T1 description: Complex tests. B = 10xxxxxx -> B in [0x80 - 0xBF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -14,9 +15,9 @@ var indexO = 0; for (var index = 0x80; index <= 0xBF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2)); + decodeURI(hex); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.3_T2.js b/test/built-ins/decodeURI/S15.1.3.1_A1.3_T2.js index 1a154784b7..a00a58dea2 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.3_T2.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.3_T2.js @@ -5,6 +5,7 @@ info: If B = 10xxxxxx or B = 11111xxx, throw URIError es5id: 15.1.3.1_A1.3_T2 description: Complex tests. B = 11111xxx -> B in [0xF8 - 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -14,9 +15,9 @@ var indexO = 0; for (var index = 0xF8; index <= 0xFF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2)); + decodeURI(hex); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.4_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.4_T1.js index 6a80cd17ab..5bc6fc1043 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.4_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.4_T1.js @@ -5,6 +5,7 @@ info: If B = 110xxxxx (n = 2) and (k + 2) + 3 >= length, throw URIError es5id: 15.1.3.1_A1.4_T1 description: Complex tests. B = [0xC0 - 0xDF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -17,9 +18,9 @@ for (var index = 0xC0; index <= 0xDF; index++) { var str = ""; var result = true; for (var len = 0; len < 3; len++) { - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + str); + decodeURI(hex + str); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -59,27 +60,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.5_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.5_T1.js index a8758ef18b..a6ed0d021f 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.5_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.5_T1.js @@ -5,6 +5,7 @@ info: If B = 1110xxxx (n = 3) and (k + 2) + 6 >= length, throw URIError es5id: 15.1.3.1_A1.5_T1 description: Complex tests. B = [0xE0 - 0xEF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -17,9 +18,9 @@ for (var index = 0xE0; index <= 0xEF; index++) { var str = ""; var result = true; for (var len = 0; len < 6; len++) { - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + str); + decodeURI(hex + str); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -59,27 +60,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.6_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.6_T1.js index 3f8347af2d..fcdc4c821b 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.6_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.6_T1.js @@ -5,6 +5,7 @@ info: If B = 11110xxx (n = 4) and (k + 2) + 9 >= length, throw URIError es5id: 15.1.3.1_A1.6_T1 description: Complex tests. B = [0xF0 - 0xF7] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -17,9 +18,9 @@ for (var index = 0xF0; index <= 0xF7; index++) { var str = ""; var result = true; for (var len = 0; len < 9; len++) { - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + str); + decodeURI(hex + str); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -59,27 +60,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.7_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.7_T1.js index 3d3b5035e1..502fb1edfd 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.7_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.7_T1.js @@ -7,6 +7,7 @@ info: > URIError es5id: 15.1.3.1_A1.7_T1 description: Complex tests. B = [0xC0 - 0xDF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,9 +17,9 @@ var indexO = 0; for (var index = 0xC0; index <= 0xDF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + "111"); + decodeURI(hex + "111"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -53,27 +54,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.8_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.8_T1.js index 387cf52f70..85d6657f21 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.8_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.8_T1.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6) not equal "%", throw URIError es5id: 15.1.3.1_A1.8_T1 description: > - Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 3) not equal - "%" + Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 3) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xE0; index <= 0xEF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + "111%A0"); + decodeURI(hex + "111%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.8_T2.js b/test/built-ins/decodeURI/S15.1.3.1_A1.8_T2.js index 95e93cfcc9..89303e011e 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.8_T2.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.8_T2.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6) not equal "%", throw URIError es5id: 15.1.3.1_A1.8_T2 description: > - Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 6) not equal - "%" + Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 6) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xE0; index <= 0xEF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + "%A0111"); + decodeURI(hex + "%A0111"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.9_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A1.9_T1.js index 31e5615798..2ec5d9b9db 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.9_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.9_T1.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError es5id: 15.1.3.1_A1.9_T1 description: > - Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 3) not equal - "%" + Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 3) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xF0; index <= 0xF7; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + "111%A0%A0"); + decodeURI(hex + "111%A0%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.9_T2.js b/test/built-ins/decodeURI/S15.1.3.1_A1.9_T2.js index 2f19944845..7d1f1808c2 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.9_T2.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.9_T2.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError es5id: 15.1.3.1_A1.9_T2 description: > - Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 6) not equal - "%" + Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 6) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xF0; index <= 0xF7; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + "%A0111%A0"); + decodeURI(hex + "%A0111%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A1.9_T3.js b/test/built-ins/decodeURI/S15.1.3.1_A1.9_T3.js index 306d946d99..8289d50a9a 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A1.9_T3.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A1.9_T3.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError es5id: 15.1.3.1_A1.9_T3 description: > - Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 9) not equal - "%" + Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 9) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xF0; index <= 0xF7; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURI("%" + hex.substring(2) + "%A0%A0111"); + decodeURI(hex + "%A0%A0111"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A2.1_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A2.1_T1.js index 7f643eb763..15890e3459 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A2.1_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A2.1_T1.js @@ -5,6 +5,7 @@ info: If string.charAt(k) not equal "%", return this char es5id: 15.1.3.1_A2.1_T1 description: Complex tests +includes: [decimalToHexString.js] ---*/ //CHECK @@ -30,27 +31,3 @@ for (var indexI = 0; indexI <= 65535; indexI++) { if (errorCount > 0) { $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A2.2_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A2.2_T1.js index ec98dc2e9a..143ea88f07 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A2.2_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A2.2_T1.js @@ -5,6 +5,7 @@ info: If B1 = 0xxxxxxxx ([0x00 - 0x7F]), without [uriReserved, #], return B1 es5id: 15.1.3.1_A2.2_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,18 +16,15 @@ var uriReserved = [";", "/", "?", ":", "@", "&", "=", "+", "$", ","]; l: for (var indexB1 = 0x00; indexB1 <= 0x7F; indexB1++) { count++; - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); var index = indexB1; - try { - var hex = String.fromCharCode(index); - for (var indexC = 0; indexC < uriReserved.length; indexC++) { - if (hex === uriReserved[indexC]) continue l; - } - if (hex === "#") continue l; - if (decodeURI("%" + hexB1.substring(2)) === hex) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + var hex = String.fromCharCode(index); + for (var indexC = 0; indexC < uriReserved.length; indexC++) { + if (hex === uriReserved[indexC]) continue l; + } + if (hex === "#") continue; + if (decodeURI(hexB1) === hex) continue; + if (indexO === 0) { indexO = index; } else { @@ -58,27 +56,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A2.3_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A2.3_T1.js index 72458cf212..5a0786823d 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A2.3_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A2.3_T1.js @@ -7,6 +7,7 @@ info: > B1 = [0xC0, 0xC1], return UTF8(B1, B2) es5id: 15.1.3.1_A2.3_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,16 +16,13 @@ var indexP; var indexO = 0; for (var indexB1 = 0xC2; indexB1 <= 0xDF; indexB1++) { - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { count++; - var hexB2 = decimalToHexString(indexB2); + var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); var index = (indexB1 & 0x1F) * 0x40 + (indexB2 & 0x3F); - try { - if (decodeURI("%" + hexB1.substring(2) + "%" + hexB2.substring(2)) === String.fromCharCode(index)) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + if (decodeURI(hexB1_B2) === String.fromCharCode(index)) continue; + if (indexO === 0) { indexO = index; } else { @@ -57,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A2.4_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A2.4_T1.js index 6558d09a94..edb3b78fca 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A2.4_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A2.4_T1.js @@ -8,6 +8,7 @@ info: > 0xDFFF), return UTF8(B1, B2, B3) es5id: 15.1.3.1_A2.4_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,20 +17,17 @@ var indexP; var indexO = 0; for (var indexB1 = 0xE0; indexB1 <= 0xEF; indexB1++) { - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { if ((indexB1 === 0xE0) && (indexB2 <= 0x9F)) continue; if ((indexB1 === 0xED) && (0xA0 <= indexB2)) continue; - var hexB2 = decimalToHexString(indexB2); + var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); for (var indexB3 = 0x80; indexB3 <= 0xBF; indexB3++) { count++; - var hexB3 = decimalToHexString(indexB3); + var hexB1_B2_B3 = hexB1_B2 + decimalToPercentHexString(indexB3); var index = (indexB1 & 0x0F) * 0x1000 + (indexB2 & 0x3F) * 0x40 + (indexB3 & 0x3F); - try { - if (decodeURI("%" + hexB1.substring(2) + "%" + hexB2.substring(2) + "%" + hexB3.substring(2)) === String.fromCharCode(index)) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + if (decodeURI(hexB1_B2_B3) === String.fromCharCode(index)) continue; + if (indexO === 0) { indexO = index; } else { @@ -63,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURI/S15.1.3.1_A2.5_T1.js b/test/built-ins/decodeURI/S15.1.3.1_A2.5_T1.js index b164850dc3..72e98b6e9a 100644 --- a/test/built-ins/decodeURI/S15.1.3.1_A2.5_T1.js +++ b/test/built-ins/decodeURI/S15.1.3.1_A2.5_T1.js @@ -8,6 +8,7 @@ info: > return UTF8(B1, B2, B3, B4) es5id: 15.1.3.1_A2.5_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,24 +17,21 @@ var indexP; var indexO = 0; for (var indexB1 = 0xF0; indexB1 <= 0xF4; indexB1++) { - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { if ((indexB1 === 0xF0) && (indexB2 <= 0x9F)) continue; if ((indexB1 === 0xF4) && (indexB2 >= 0x90)) continue; - var hexB2 = decimalToHexString(indexB2); + var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); for (var indexB3 = 0x80; indexB3 <= 0xBF; indexB3++) { - var hexB3 = decimalToHexString(indexB3); + var hexB1_B2_B3 = hexB1_B2 + decimalToPercentHexString(indexB3); for (var indexB4 = 0x80; indexB4 <= 0xBF; indexB4++) { - var hexB4 = decimalToHexString(indexB4); + var hexB1_B2_B3_B4 = hexB1_B2_B3 + decimalToPercentHexString(indexB4); count++; var index = (indexB1 & 0x07) * 0x40000 + (indexB2 & 0x3F) * 0x1000 + (indexB3 & 0x3F) * 0x40 + (indexB4 & 0x3F); var L = ((index - 0x10000) & 0x03FF) + 0xDC00; var H = (((index - 0x10000) >> 10) & 0x03FF) + 0xD800; - try { - if (decodeURI("%" + hexB1.substring(3) + "%" + hexB2.substring(3) + "%" + hexB3.substring(3) + "%" + hexB4.substring(3)) === String.fromCharCode(H) + String.fromCharCode(L)) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + if (decodeURI(hexB1_B2_B3_B4) === String.fromCharCode(H, L)) continue; + if (indexO === 0) { indexO = index; } else { @@ -68,27 +66,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 4; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T1.js index 4aa20cee26..978e7517a9 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T1.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.13_T1 description: Complex tests. B = [0xC0 - 0xDF], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xC0; indexB <= 0xDF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%" + hexC.substring(2)); + decodeURIComponent(hexB + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T2.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T2.js index bba768aac2..cac109a333 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T2.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.13_T2.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.13_T2 description: Complex tests. B = [0xC0 - 0xDF], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xC0; indexB <= 0xDF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%" + hexC.substring(2)); + decodeURIComponent(hexB + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T1.js index 3f4ce70a37..1993a13420 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T1.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.14_T1 description: Complex tests. B = [0xE0 - 0xEF], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0"); + decodeURIComponent(hexB + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T2.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T2.js index b028c21a3e..5d5c9a7376 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T2.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T2.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.14_T2 description: Complex tests. B = [0xE0 - 0xEF], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2)); + decodeURIComponent(hexB + "%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T3.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T3.js index 690481bdc6..6153a20932 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T3.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T3.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.14_T3 description: Complex tests. B = [0xE0 - 0xEF], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0"); + decodeURIComponent(hexB + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T4.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T4.js index 4c2d987473..04a8121d15 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T4.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.14_T4.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.14_T4 description: Complex tests. B = [0xE0 - 0xEF], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xE0; indexB <= 0xEF; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2)); + decodeURIComponent(hexB + "%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T1.js index 28861fab19..322785b1e2 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T1.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.15_T1 description: Complex tests. B = [0xF0 - 0x0F7], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0%A0"); + decodeURIComponent(hexB + hexC + "%A0%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T2.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T2.js index 6937c01f28..a6a40ba88e 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T2.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T2.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.15_T2 description: Complex tests. B = [0xF0 - 0x0F7], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2) + "%A0"); + decodeURIComponent(hexB + "%A0" + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T3.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T3.js index cb966fd6bd..f503082b2c 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T3.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T3.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.15_T3 description: Complex tests. B = [0xF0 - 0x0F7], C = [0x00, 0x7F] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0x00; indexC <= 0x7F; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%A0%A0" + "%" + hexC.substring(2)); + decodeURIComponent(hexB + "%A0%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T4.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T4.js index dff7c9a850..b752791481 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T4.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T4.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.15_T4 description: Complex tests. B = [0xF0 - 0x0F7], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%" + hexC.substring(2) + "%A0%A0"); + decodeURIComponent(hexB + hexC + "%A0%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T5.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T5.js index 0220be857d..072aabdd65 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T5.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T5.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.15_T5 description: Complex tests. B = [0xF0 - 0x0F7], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%A0" + "%" + hexC.substring(2) + "%A0"); + decodeURIComponent(hexB + "%A0" + hexC + "%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T6.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T6.js index 02941b07e6..777672e792 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T6.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.15_T6.js @@ -7,6 +7,7 @@ info: > throw URIError es5id: 15.1.3.2_A1.15_T6 description: Complex tests. B = [0xF0 - 0x0F7], C = [0xC0, 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,12 @@ var indexO = 0; for (var indexB = 0xF0; indexB <= 0xF7; indexB++) { count++; - var hexB = decimalToHexString(indexB); + var hexB = decimalToPercentHexString(indexB); var result = true; for (var indexC = 0xC0; indexC <= 0xFF; indexC++) { - var hexC = decimalToHexString(indexC); + var hexC = decimalToPercentHexString(indexC); try { - decodeURIComponent("%" + hexB.substring(2) + "%A0%A0" + "%" + hexC.substring(2)); + decodeURIComponent(hexB + "%A0%A0" + hexC); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -60,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T1.js index 98a0977a78..99073d74dd 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T1.js @@ -5,6 +5,7 @@ info: If B = 10xxxxxx or B = 11111xxx, throw URIError es5id: 15.1.3.2_A1.3_T1 description: Complex tests. B = 10xxxxxx -> B in [0x80 - 0xBF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -14,9 +15,9 @@ var indexO = 0; for (var index = 0x80; index <= 0xBF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2)); + decodeURIComponent(hex); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T2.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T2.js index 9d0bfc1667..d4cdfc6ff6 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T2.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.3_T2.js @@ -5,6 +5,7 @@ info: If B = 10xxxxxx or B = 11111xxx, throw URIError es5id: 15.1.3.2_A1.3_T2 description: Complex tests. B = 11111xxx -> B in [0xF8 - 0xFF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -14,9 +15,9 @@ var indexO = 0; for (var index = 0xF8; index <= 0xFF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2)); + decodeURIComponent(hex); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.4_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.4_T1.js index 7e88a8d05f..97108d76a6 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.4_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.4_T1.js @@ -5,6 +5,7 @@ info: If B = 110xxxxx (n = 2) and (k + 2) + 3 >= length, throw URIError es5id: 15.1.3.2_A1.4_T1 description: Complex tests. B = [0xC0 - 0xDF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -17,9 +18,9 @@ for (var index = 0xC0; index <= 0xDF; index++) { var str = ""; var result = true; for (var len = 0; len < 3; len++) { - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + str); + decodeURIComponent(hex + str); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -59,27 +60,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.5_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.5_T1.js index ef72254a57..782bb26d40 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.5_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.5_T1.js @@ -5,6 +5,7 @@ info: If B = 1110xxxx (n = 3) and (k + 2) + 6 >= length, throw URIError es5id: 15.1.3.2_A1.5_T1 description: Complex tests. B = [0xE0 - 0xEF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -17,9 +18,9 @@ for (var index = 0xE0; index <= 0xEF; index++) { var str = ""; var result = true; for (var len = 0; len < 6; len++) { - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + str); + decodeURIComponent(hex + str); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -59,27 +60,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.6_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.6_T1.js index 3c68d04c68..8e5e0f6764 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.6_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.6_T1.js @@ -5,6 +5,7 @@ info: If B = 11110xxx (n = 4) and (k + 2) + 9 >= length, throw URIError es5id: 15.1.3.2_A1.6_T1 description: Complex tests. B = [0xF0 - 0xF7] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -17,9 +18,9 @@ for (var index = 0xF0; index <= 0xF7; index++) { var str = ""; var result = true; for (var len = 0; len < 9; len++) { - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + str); + decodeURIComponent(hex + str); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -59,27 +60,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.7_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.7_T1.js index 092e4602de..488c589d3f 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.7_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.7_T1.js @@ -7,6 +7,7 @@ info: > URIError es5id: 15.1.3.2_A1.7_T1 description: Complex tests. B = [0xC0 - 0xDF] +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,9 +17,9 @@ var indexO = 0; for (var index = 0xC0; index <= 0xDF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + "111"); + decodeURIComponent(hex + "111"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -53,27 +54,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T1.js index 6871ba649a..672cc54437 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T1.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6) not equal "%", throw URIError es5id: 15.1.3.2_A1.8_T1 description: > - Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 3) not equal - "%" + Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 3) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xE0; index <= 0xEF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + "111%A0"); + decodeURIComponent(hex + "111%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T2.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T2.js index 5a5c1df077..d562ac053e 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T2.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.8_T2.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6) not equal "%", throw URIError es5id: 15.1.3.2_A1.8_T2 description: > - Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 6) not equal - "%" + Complex tests. B = [0xE0 - 0xEF], string.charAt(k + 6) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xE0; index <= 0xEF; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + "%A0111"); + decodeURIComponent(hex + "%A0111"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T1.js index 8b3ebb23fe..f2b31216a2 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T1.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError es5id: 15.1.3.2_A1.9_T1 description: > - Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 3) not equal - "%" + Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 3) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xF0; index <= 0xF7; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + "111%A0%A0"); + decodeURIComponent(hex + "111%A0%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T2.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T2.js index 664cc07d32..1033aa1ae2 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T2.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T2.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError es5id: 15.1.3.2_A1.9_T2 description: > - Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 6) not equal - "%" + Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 6) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xF0; index <= 0xF7; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + "%A0111%A0"); + decodeURIComponent(hex + "%A0111%A0"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T3.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T3.js index 5f5813ace8..22f48126d8 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T3.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A1.9_T3.js @@ -7,8 +7,8 @@ info: > string.charAt(k + 6), string.charAt(k + 9) not equal "%", throw URIError es5id: 15.1.3.2_A1.9_T3 description: > - Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 9) not equal - "%" + Complex tests. B = [0xF0 - 0x0F7], string.charAt(k + 9) not equal "%" +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -18,9 +18,9 @@ var indexO = 0; for (var index = 0xF0; index <= 0xF7; index++) { count++; - var hex = decimalToHexString(index); + var hex = decimalToPercentHexString(index); try { - decodeURIComponent("%" + hex.substring(2) + "%A0%A0111"); + decodeURIComponent(hex + "%A0%A0111"); } catch (e) { if ((e instanceof URIError) === true) continue; } @@ -55,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.1_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.1_T1.js index 6e5b14179e..05c7db39f7 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.1_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.1_T1.js @@ -5,6 +5,7 @@ info: If string.charAt(k) not equal "%", return this char es5id: 15.1.3.2_A2.1_T1 description: Complex tests +includes: [decimalToHexString.js] ---*/ //CHECK @@ -30,27 +31,3 @@ for (var indexI = 0; indexI <= 65535; indexI++) { if (errorCount > 0) { $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.2_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.2_T1.js index 6d6811929e..59074ba2dd 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.2_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.2_T1.js @@ -5,6 +5,7 @@ info: If B1 = 0xxxxxxxx ([0x00 - 0x7F]), return B1 es5id: 15.1.3.2_A2.2_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -13,14 +14,11 @@ var indexP; var indexO = 0; for (var indexB1 = 0x00; indexB1 <= 0x7F; indexB1++) { count++; - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); var index = indexB1; - try { - var hex = String.fromCharCode(index); - if (decodeURIComponent("%" + hexB1.substring(2)) === hex) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + var hex = String.fromCharCode(index); + if (decodeURIComponent(hexB1) === hex) continue; + if (indexO === 0) { indexO = index; } else { @@ -52,27 +50,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.3_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.3_T1.js index 2d40ec6644..14edea9c3b 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.3_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.3_T1.js @@ -7,6 +7,7 @@ info: > B1 = [0xC0, 0xC1], return UTF8(B1, B2) es5id: 15.1.3.2_A2.3_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,16 +16,13 @@ var indexP; var indexO = 0; for (var indexB1 = 0xC2; indexB1 <= 0xDF; indexB1++) { - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { count++; - var hexB2 = decimalToHexString(indexB2); + var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); var index = (indexB1 & 0x1F) * 0x40 + (indexB2 & 0x3F); - try { - if (decodeURIComponent("%" + hexB1.substring(2) + "%" + hexB2.substring(2)) === String.fromCharCode(index)) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + if (decodeURIComponent(hexB1_B2) === String.fromCharCode(index)) continue; + if (indexO === 0) { indexO = index; } else { @@ -57,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.4_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.4_T1.js index 03adf9a89e..8c6678e8f6 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.4_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.4_T1.js @@ -8,6 +8,7 @@ info: > 0xDFFF), return UTF8(B1, B2, B3) es5id: 15.1.3.2_A2.4_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,20 +17,17 @@ var indexP; var indexO = 0; for (var indexB1 = 0xE0; indexB1 <= 0xEF; indexB1++) { - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { if ((indexB1 === 0xE0) && (indexB2 <= 0x9F)) continue; if ((indexB1 === 0xED) && (0xA0 <= indexB2)) continue; - var hexB2 = decimalToHexString(indexB2); + var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); for (var indexB3 = 0x80; indexB3 <= 0xBF; indexB3++) { count++; - var hexB3 = decimalToHexString(indexB3); + var hexB1_B2_B3 = hexB1_B2 + decimalToPercentHexString(indexB3); var index = (indexB1 & 0x0F) * 0x1000 + (indexB2 & 0x3F) * 0x40 + (indexB3 & 0x3F); - try { - if (decodeURIComponent("%" + hexB1.substring(2) + "%" + hexB2.substring(2) + "%" + hexB3.substring(2)) === String.fromCharCode(index)) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + if (decodeURIComponent(hexB1_B2_B3) === String.fromCharCode(index)) continue; + if (indexO === 0) { indexO = index; } else { @@ -63,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.5_T1.js b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.5_T1.js index 6a2d55ae71..42cbda2245 100644 --- a/test/built-ins/decodeURIComponent/S15.1.3.2_A2.5_T1.js +++ b/test/built-ins/decodeURIComponent/S15.1.3.2_A2.5_T1.js @@ -8,6 +8,7 @@ info: > return UTF8(B1, B2, B3, B4) es5id: 15.1.3.2_A2.5_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,24 +17,21 @@ var indexP; var indexO = 0; for (var indexB1 = 0xF0; indexB1 <= 0xF4; indexB1++) { - var hexB1 = decimalToHexString(indexB1); + var hexB1 = decimalToPercentHexString(indexB1); for (var indexB2 = 0x80; indexB2 <= 0xBF; indexB2++) { if ((indexB1 === 0xF0) && (indexB2 <= 0x9F)) continue; if ((indexB1 === 0xF4) && (indexB2 >= 0x90)) continue; - var hexB2 = decimalToHexString(indexB2); + var hexB1_B2 = hexB1 + decimalToPercentHexString(indexB2); for (var indexB3 = 0x80; indexB3 <= 0xBF; indexB3++) { - var hexB3 = decimalToHexString(indexB3); + var hexB1_B2_B3 = hexB1_B2 + decimalToPercentHexString(indexB3); for (var indexB4 = 0x80; indexB4 <= 0xBF; indexB4++) { - var hexB4 = decimalToHexString(indexB4); + var hexB1_B2_B3_B4 = hexB1_B2_B3 + decimalToPercentHexString(indexB4); count++; var index = (indexB1 & 0x07) * 0x40000 + (indexB2 & 0x3F) * 0x1000 + (indexB3 & 0x3F) * 0x40 + (indexB4 & 0x3F); var L = ((index - 0x10000) & 0x03FF) + 0xDC00; var H = (((index - 0x10000) >> 10) & 0x03FF) + 0xD800; - try { - if (decodeURIComponent("%" + hexB1.substring(3) + "%" + hexB2.substring(3) + "%" + hexB3.substring(3) + "%" + hexB4.substring(3)) === String.fromCharCode(H) + String.fromCharCode(L)) continue; - } catch (e) { - if (e instanceof Test262Error) throw e; - } + if (decodeURIComponent(hexB1_B2_B3_B4) === String.fromCharCode(H, L)) continue; + if (indexO === 0) { indexO = index; } else { @@ -68,27 +66,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 4; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A1.1_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A1.1_T1.js index 35da750488..781519c5eb 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A1.1_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A1.1_T1.js @@ -5,6 +5,7 @@ info: If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError es5id: 15.1.3.3_A1.1_T1 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A1.1_T2.js b/test/built-ins/encodeURI/S15.1.3.3_A1.1_T2.js index b52327b992..0d3b4a9700 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A1.1_T2.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A1.1_T2.js @@ -5,6 +5,7 @@ info: If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError es5id: 15.1.3.3_A1.1_T2 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A1.2_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A1.2_T1.js index 0180fd539e..26cb4751a0 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A1.2_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A1.2_T1.js @@ -7,6 +7,7 @@ info: > URIError es5id: 15.1.3.3_A1.2_T1 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -53,27 +54,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A1.2_T2.js b/test/built-ins/encodeURI/S15.1.3.3_A1.2_T2.js index c23c66be6a..d55e3bfaff 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A1.2_T2.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A1.2_T2.js @@ -7,6 +7,7 @@ info: > URIError es5id: 15.1.3.3_A1.2_T2 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -53,27 +54,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A1.3_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A1.3_T1.js index 20ffa34377..74acbdace1 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A1.3_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A1.3_T1.js @@ -9,6 +9,7 @@ es5id: 15.1.3.3_A1.3_T1 description: > Complex tests, string.charAt(k+1) in [0x0000, 0xD7FF, 0xD800, 0xDBFE, 0xDBFF, 0xE000, 0xFFFF] +includes: [decimalToHexString.js] ---*/ var chars = [0x0000, 0xD7FF, 0xD800, 0xDBFE, 0xDBFF, 0xE000, 0xFFFF]; @@ -62,27 +63,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A2.1_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A2.1_T1.js index 9cbd48a4bb..7074472ac5 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A2.1_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A2.1_T1.js @@ -7,6 +7,7 @@ info: > return 1 octet (00000000 0zzzzzzz -> 0zzzzzzz) es5id: 15.1.3.3_A2.1_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var uriReserved = [";", "/", "?", ":", "@", "&", "=", "+", "$", ","]; @@ -27,9 +28,8 @@ for (var index = 0x0000; index <= 0x007F; index++) { if (uriUnescaped[indexC] === str) continue l; } if ("#" === str) continue l; - try { - if (encodeURI(str).toUpperCase() === "%" + decimalToHexString(index).substring(2)) continue l; - } catch(e) {} + if (encodeURI(str).toUpperCase() === decimalToPercentHexString(index)) continue l; + if (indexO === 0) { indexO = index; } else { @@ -61,27 +61,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A2.2_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A2.2_T1.js index 32d069d8c6..e293339abe 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A2.2_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A2.2_T1.js @@ -7,6 +7,7 @@ info: > yyzzzzzz -> 110yyyyy 10zzzzzz) es5id: 15.1.3.3_A2.2_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,11 @@ var indexO = 0; l: for (var index = 0x0080; index <= 0x07FF; index++) { count++; - var hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x00C0 + (index & 0x07C0) / 0x0040).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x00C0 + (index & 0x07C0) / 0x0040); var str = String.fromCharCode(index); - try { - if (encodeURI(str).toUpperCase() === "%" + hex2 + "%" + hex1) continue; - } catch(e) {} + if (encodeURI(str).toUpperCase() === hex2 + hex1) continue; + if (indexO === 0) { indexO = index; } else { @@ -53,27 +53,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A2.3_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A2.3_T1.js index 9a6588fab1..c12383a20f 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A2.3_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A2.3_T1.js @@ -7,6 +7,7 @@ info: > yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz) es5id: 15.1.3.3_A2.3_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,13 +16,12 @@ var indexP; var indexO = 0; for (var index = 0x0800; index <= 0xD7FF; index++) { count++; - var hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x00E0 + (index & 0xF000) / 0x1000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x00E0 + (index & 0xF000) / 0x1000); var str = String.fromCharCode(index); - try { - if (encodeURI(str).toUpperCase() === "%" + hex3 + "%" + hex2 + "%" + hex1) continue; - } catch(e) {} + if (encodeURI(str).toUpperCase() === hex3 + hex2 + hex1) continue; + if (indexO === 0) { indexO = index; } else { @@ -53,27 +53,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A2.4_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A2.4_T1.js index 7c98072e49..838b038bde 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A2.4_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A2.4_T1.js @@ -10,6 +10,7 @@ es5id: 15.1.3.3_A2.4_T1 description: > Complex tests, use RFC 3629, string.charAt(k+1) in [0xDC00, 0xDDFF, 0xDFFF] +includes: [decimalToHexString.js] ---*/ var chars = [0xDC00, 0xDDFF, 0xDFFF]; @@ -21,16 +22,14 @@ for (var index = 0xD800; index <= 0xDBFF; index++) { var res = true; for (var indexC = 0; indexC < chars.length; indexC++) { var index1 = (index - 0xD800) * 0x400 + (chars[indexC] - 0xDC00) + 0x10000; - var hex1 = decimalToHexString(0x0080 + (index1 & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index1 & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x0080 + (index1 & 0x3F000) / 0x1000).substring(2); - var hex4 = decimalToHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index1 & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index1 & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x0080 + (index1 & 0x3F000) / 0x1000); + var hex4 = decimalToPercentHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000); var str = String.fromCharCode(index, chars[indexC]); - try { - if (encodeURI(str).toUpperCase() !== "%" + hex4 + "%" + hex3 + "%" + hex2 + "%" + hex1) { - res = false; - } - } catch(e) {res = false} + if (encodeURI(str).toUpperCase() === hex4 + hex3 + hex2 + hex1) continue; + + res = false; } if (res !== true) { if (indexO === 0) { @@ -66,27 +65,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A2.4_T2.js b/test/built-ins/encodeURI/S15.1.3.3_A2.4_T2.js index 45887396eb..9d6643f908 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A2.4_T2.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A2.4_T2.js @@ -10,6 +10,7 @@ es5id: 15.1.3.3_A2.4_T2 description: > Complex tests, use RFC 3629, string.charAt(k) in [0xD800, 0xDBFF, 0xD9FF] +includes: [decimalToHexString.js] ---*/ var chars = [0xD800, 0xDBFF, 0xD9FF]; @@ -21,16 +22,14 @@ for (var index = 0xDC00; index <= 0xDFFF; index++) { var res = true; for (var indexC = 0; indexC < chars.length; indexC++) { var index1 = (chars[indexC] - 0xD800) * 0x400 + (index - 0xDC00) + 0x10000; - var hex1 = decimalToHexString(0x0080 + (index1 & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index1 & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x0080 + (index1 & 0x3F000) / 0x1000).substring(2); - var hex4 = decimalToHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index1 & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index1 & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x0080 + (index1 & 0x3F000) / 0x1000); + var hex4 = decimalToPercentHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000); var str = String.fromCharCode(chars[indexC], index); - try { - if (encodeURI(str).toUpperCase() !== "%" + hex4 + "%" + hex3 + "%" + hex2 + "%" + hex1) { - res = false; - } - } catch(e) {res = false} + if (encodeURI(str).toUpperCase() === hex4 + hex3 + hex2 + hex1) continue; + + res = false; } if (res !== true) { if (indexO === 0) { @@ -66,27 +65,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURI/S15.1.3.3_A2.5_T1.js b/test/built-ins/encodeURI/S15.1.3.3_A2.5_T1.js index cf21872824..21bd6e5a55 100644 --- a/test/built-ins/encodeURI/S15.1.3.3_A2.5_T1.js +++ b/test/built-ins/encodeURI/S15.1.3.3_A2.5_T1.js @@ -7,6 +7,7 @@ info: > yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz) es5id: 15.1.3.3_A2.5_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,13 +16,12 @@ var indexP; var indexO = 0; for (var index = 0xE000; index <= 0xFFFF; index++) { count++; - var hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x00E0 + (index & 0xF000) / 0x1000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x00E0 + (index & 0xF000) / 0x1000); var str = String.fromCharCode(index); - try { - if (encodeURI(str).toUpperCase() === "%" + hex3 + "%" + hex2 + "%" + hex1) continue; - } catch(e) {} + if (encodeURI(str).toUpperCase() === hex3 + hex2 + hex1) continue; + if (indexO === 0) { indexO = index; } else { @@ -53,27 +53,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js index 99fd5ae1e0..3e16943a2a 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js @@ -5,6 +5,7 @@ info: If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError es5id: 15.1.3.4_A1.1_T1 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js index ba5316447e..a5cf69ae0e 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js @@ -5,6 +5,7 @@ info: If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError es5id: 15.1.3.4_A1.1_T2 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -51,27 +52,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js index 740356e676..99db50d9f8 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js @@ -7,6 +7,7 @@ info: > URIError es5id: 15.1.3.4_A1.2_T1 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -53,27 +54,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js index c60733689a..fb406d723c 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js @@ -7,6 +7,7 @@ info: > URIError es5id: 15.1.3.4_A1.2_T2 description: Complex tests +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -53,27 +54,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js index d63f0f3bc8..1338e6b589 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js @@ -9,6 +9,7 @@ es5id: 15.1.3.4_A1.3_T1 description: > Complex tests, string.charAt(k+1) in [0x0000, 0xD7FF, 0xD800, 0xDBFE, 0xDBFF, 0xE000, 0xFFFF] +includes: [decimalToHexString.js] ---*/ var chars = [0x0000, 0xD7FF, 0xD800, 0xDBFE, 0xDBFF, 0xE000, 0xFFFF]; @@ -62,27 +63,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js index 808dce688d..1f09fa39e0 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js @@ -7,6 +7,7 @@ info: > (00000000 0zzzzzzz -> 0zzzzzzz) es5id: 15.1.3.4_A2.1_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var uriUnescaped = ["-", "_", ".", "!", "~", "*", "'", "(", ")", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; @@ -22,9 +23,8 @@ for (var index = 0x0000; index <= 0x007F; index++) { for (var indexC = 0; indexC < uriUnescaped.length; indexC++) { if (uriUnescaped[indexC] === str) continue l; } - try { - if (encodeURIComponent(str).toUpperCase() === "%" + decimalToHexString(index).substring(2)) continue l; - } catch(e) {} + if (encodeURIComponent(str).toUpperCase() === decimalToPercentHexString(index)) continue l; + if (indexO === 0) { indexO = index; } else { @@ -56,27 +56,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js index eccd3cdaa9..8ee2d440d0 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js @@ -7,6 +7,7 @@ info: > yyzzzzzz -> 110yyyyy 10zzzzzz) es5id: 15.1.3.4_A2.2_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -16,12 +17,11 @@ var indexO = 0; l: for (var index = 0x0080; index <= 0x07FF; index++) { count++; - var hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x00C0 + (index & 0x07C0) / 0x0040).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x00C0 + (index & 0x07C0) / 0x0040); var str = String.fromCharCode(index); - try { - if (encodeURIComponent(str).toUpperCase() === "%" + hex2 + "%" + hex1) continue; - } catch(e) {} + if (encodeURIComponent(str).toUpperCase() === hex2 + hex1) continue; + if (indexO === 0) { indexO = index; } else { @@ -53,27 +53,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js index 41ada6f405..c2dd431315 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js @@ -7,6 +7,7 @@ info: > yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz) es5id: 15.1.3.4_A2.3_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,13 +16,12 @@ var indexP; var indexO = 0; for (var index = 0x0800; index <= 0xD7FF; index++) { count++; - var hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x00E0 + (index & 0xF000) / 0x1000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x00E0 + (index & 0xF000) / 0x1000); var str = String.fromCharCode(index); - try { - if (encodeURIComponent(str).toUpperCase() === "%" + hex3 + "%" + hex2 + "%" + hex1) continue; - } catch(e) {} + if (encodeURIComponent(str).toUpperCase() === hex3 + hex2 + hex1) continue; + if (indexO === 0) { indexO = index; } else { @@ -53,27 +53,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js index bb7ba1ddb6..94164c98c1 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js @@ -10,6 +10,7 @@ es5id: 15.1.3.4_A2.4_T1 description: > Complex tests, use RFC 3629, string.charAt(k+1) in [0xDC00, 0xDDFF, 0xDFFF] +includes: [decimalToHexString.js] ---*/ var chars = [0xDC00, 0xDDFF, 0xDFFF]; @@ -21,16 +22,14 @@ for (var index = 0xD800; index <= 0xDBFF; index++) { var res = true; for (var indexC = 0; indexC < chars.length; indexC++) { var index1 = (index - 0xD800) * 0x400 + (chars[indexC] - 0xDC00) + 0x10000; - var hex1 = decimalToHexString(0x0080 + (index1 & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index1 & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x0080 + (index1 & 0x3F000) / 0x1000).substring(2); - var hex4 = decimalToHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index1 & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index1 & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x0080 + (index1 & 0x3F000) / 0x1000); + var hex4 = decimalToPercentHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000); var str = String.fromCharCode(index, chars[indexC]); - try { - if (encodeURIComponent(str).toUpperCase() !== "%" + hex4 + "%" + hex3 + "%" + hex2 + "%" + hex1) { - res = false; - } - } catch(e) {res = false} + if (encodeURIComponent(str).toUpperCase() === hex4 + hex3 + hex2 + hex1) continue; + + res = false; } if (res !== true) { if (indexO === 0) { @@ -66,27 +65,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js index 9ff448ecba..3fd3d0a4c2 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js @@ -10,6 +10,7 @@ es5id: 15.1.3.4_A2.4_T2 description: > Complex tests, use RFC 3629, string.charAt(k) in [0xD800, 0xDBFF, 0xD9FF] +includes: [decimalToHexString.js] ---*/ var chars = [0xD800, 0xDBFF, 0xD9FF]; @@ -21,16 +22,14 @@ for (var index = 0xDC00; index <= 0xDFFF; index++) { var res = true; for (var indexC = 0; indexC < chars.length; indexC++) { var index1 = (chars[indexC] - 0xD800) * 0x400 + (index - 0xDC00) + 0x10000; - var hex1 = decimalToHexString(0x0080 + (index1 & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index1 & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x0080 + (index1 & 0x3F000) / 0x1000).substring(2); - var hex4 = decimalToHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index1 & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index1 & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x0080 + (index1 & 0x3F000) / 0x1000); + var hex4 = decimalToPercentHexString(0x00F0 + (index1 & 0x1C0000) / 0x40000); var str = String.fromCharCode(chars[indexC], index); - try { - if (encodeURIComponent(str).toUpperCase() !== "%" + hex4 + "%" + hex3 + "%" + hex2 + "%" + hex1) { - res = false; - } - } catch(e) {res = false} + if (encodeURIComponent(str).toUpperCase() === hex4 + hex3 + hex2 + hex1) continue; + + res = false; } if (res !== true) { if (indexO === 0) { @@ -66,27 +65,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js index 22f7445e79..2f68bcf052 100644 --- a/test/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js +++ b/test/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js @@ -7,6 +7,7 @@ info: > yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz) es5id: 15.1.3.4_A2.5_T1 description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] ---*/ var errorCount = 0; @@ -15,13 +16,12 @@ var indexP; var indexO = 0; for (var index = 0xE000; index <= 0xFFFF; index++) { count++; - var hex1 = decimalToHexString(0x0080 + (index & 0x003F)).substring(2); - var hex2 = decimalToHexString(0x0080 + (index & 0x0FC0) / 0x0040).substring(2); - var hex3 = decimalToHexString(0x00E0 + (index & 0xF000) / 0x1000).substring(2); + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x0080 + (index & 0x0FC0) / 0x0040); + var hex3 = decimalToPercentHexString(0x00E0 + (index & 0xF000) / 0x1000); var str = String.fromCharCode(index); - try { - if (encodeURIComponent(str).toUpperCase() === "%" + hex3 + "%" + hex2 + "%" + hex1) continue; - } catch(e) {} + if (encodeURIComponent(str).toUpperCase() === hex3 + hex2 + hex1) continue; + if (indexO === 0) { indexO = index; } else { @@ -53,27 +53,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/parseFloat/S15.1.2.3_A6.js b/test/built-ins/parseFloat/S15.1.2.3_A6.js index a9983ac278..a1fc0eead0 100644 --- a/test/built-ins/parseFloat/S15.1.2.3_A6.js +++ b/test/built-ins/parseFloat/S15.1.2.3_A6.js @@ -9,6 +9,7 @@ info: > characters were ignored. es5id: 15.1.2.3_A6 description: Complex test without eval +includes: [decimalToHexString.js] ---*/ //CHECK @@ -54,27 +55,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -} diff --git a/test/built-ins/parseInt/S15.1.2.2_A8.js b/test/built-ins/parseInt/S15.1.2.2_A8.js index 5aabbdedd8..030c7b67d7 100644 --- a/test/built-ins/parseInt/S15.1.2.2_A8.js +++ b/test/built-ins/parseInt/S15.1.2.2_A8.js @@ -9,6 +9,7 @@ info: > characters were ignored. es5id: 15.1.2.2_A8 description: Complex test without eval +includes: [decimalToHexString.js] ---*/ //CHECK @@ -56,27 +57,3 @@ if (errorCount > 0) { } $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); } - -function decimalToHexString(n) { - n = Number(n); - var h = ""; - for (var i = 3; i >= 0; i--) { - if (n >= Math.pow(16, i)) { - var t = Math.floor(n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { h += "A"; } - if ( t == 11 ) { h += "B"; } - if ( t == 12 ) { h += "C"; } - if ( t == 13 ) { h += "D"; } - if ( t == 14 ) { h += "E"; } - if ( t == 15 ) { h += "F"; } - } else { - h += String(t); - } - } else { - h += "0"; - } - } - return h; -}