diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/built-ins/encodeURIComponent | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/encodeURIComponent')
33 files changed, 1274 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js new file mode 100644 index 0000000000..5f50da54c9 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError +esid: sec-encodeuricomponent-uricomponent +description: Complex tests +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; + +for (var index = 0xDC00; index <= 0xDFFF; index++) { + count++; + var hex = decimalToHexString(index); + try { + encodeURIComponent(String.fromCharCode(index)); + } catch (e) { + if ((e instanceof URIError) === true) continue; + } + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js new file mode 100644 index 0000000000..97698bfbc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If string.charAt(k) in [0xDC00 - 0xDFFF], throw URIError +esid: sec-encodeuricomponent-uricomponent +description: Complex tests +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; + +for (var index = 0xDC00; index <= 0xDFFF; index++) { + count++; + var hex = decimalToHexString(index); + try { + encodeURIComponent(String.fromCharCode(index, 0x0041)); + } catch (e) { + if ((e instanceof URIError) === true) continue; + } + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js new file mode 100644 index 0000000000..5f815d8b1b --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T1.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0xD800 - 0xDBFF] and string.length = k + 1, throw + URIError +esid: sec-encodeuricomponent-uricomponent +description: Complex tests +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; + +for (var index = 0xD800; index <= 0xDBFF; index++) { + count++; + var hex = decimalToHexString(index); + try { + encodeURIComponent(String.fromCharCode(index)); + } catch (e) { + if ((e instanceof URIError) === true) continue; + } + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js new file mode 100644 index 0000000000..1e8a7caa7d --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0xD800 - 0xDBFF] and string.length = k + 1, throw + URIError +esid: sec-encodeuricomponent-uricomponent +description: Complex tests +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; + +for (var index = 0xD800; index <= 0xDBFF; index++) { + count++; + var hex = decimalToHexString(index); + try { + encodeURIComponent(String.fromCharCode(0x0041, index)); + } catch (e) { + if ((e instanceof URIError) === true) continue; + } + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js new file mode 100644 index 0000000000..3591c82a63 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js @@ -0,0 +1,67 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0xD800 - 0xDBFF] and string.charAt(k+1) not in + [0xDC00 - 0xDFFF], throw URIError +esid: sec-encodeuricomponent-uricomponent +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]; +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; + +for (var index = 0xD800; index <= 0xDBFF; index++) { + count++; + var res = true; + for (var indexC = 0; indexC < chars.length; indexC++) { + var hex = decimalToHexString(index); + try { + encodeURIComponent(String.fromCharCode(index, chars[indexC])); + } catch (e) { + if ((e instanceof URIError) === true) continue; + } + res = false; + } + if (res !== true) { + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js new file mode 100644 index 0000000000..282669aca0 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.1_T1.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0x0000 - 0x007F]\[uriUnescaped], return 1 octet + (00000000 0zzzzzzz -> 0zzzzzzz) +esid: sec-encodeuricomponent-uricomponent +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"]; +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; + +l: + for (var index = 0x0000; index <= 0x007F; index++) { + count++; + var str = String.fromCharCode(index); + for (var indexC = 0; indexC < uriUnescaped.length; indexC++) { + if (uriUnescaped[indexC] === str) continue l; + } + if (encodeURIComponent(str).toUpperCase() === decimalToPercentHexString(index)) continue l; + + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js new file mode 100644 index 0000000000..09d4bbad73 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.2_T1.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0x0080 - 0x07FF], return 2 octets (00000yyy + yyzzzzzz -> 110yyyyy 10zzzzzz) +esid: sec-encodeuricomponent-uricomponent +description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; +l: + for (var index = 0x0080; index <= 0x07FF; index++) { + count++; + var hex1 = decimalToPercentHexString(0x0080 + (index & 0x003F)); + var hex2 = decimalToPercentHexString(0x00C0 + (index & 0x07C0) / 0x0040); + var str = String.fromCharCode(index); + if (encodeURIComponent(str).toUpperCase() === hex2 + hex1) continue; + + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js new file mode 100644 index 0000000000..7c33682bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.3_T1.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0x0800 - 0xD7FF], return 3 octets (xxxxyyyy + yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz) +esid: sec-encodeuricomponent-uricomponent +description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; +for (var index = 0x0800; index <= 0xD7FF; index++) { + count++; + 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); + if (encodeURIComponent(str).toUpperCase() === hex3 + hex2 + hex1) continue; + + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js new file mode 100644 index 0000000000..c3add1ceaf --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T1.js @@ -0,0 +1,69 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0xD800 - 0xDBFF] and string.charAt(k+1) in + [0xDC00 � 0xDFFF], return 4 octets (000wwwxx xxxxyyyy yyzzzzzz -> + 11110www 10xxxxxx 10yyyyyy 10zzzzzz) +esid: sec-encodeuricomponent-uricomponent +description: > + Complex tests, use RFC 3629, string.charAt(k+1) in [0xDC00, + 0xDDFF, 0xDFFF] +includes: [decimalToHexString.js] +---*/ + +var chars = [0xDC00, 0xDDFF, 0xDFFF]; +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; +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 = 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]); + if (encodeURIComponent(str).toUpperCase() === hex4 + hex3 + hex2 + hex1) continue; + + res = false; + } + if (res !== true) { + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + count++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js new file mode 100644 index 0000000000..ddbd06fea0 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.4_T2.js @@ -0,0 +1,69 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0xD800 - 0xDBFF] and string.charAt(k+1) in + [0xDC00 � 0xDFFF], return 4 octets (000wwwxx xxxxyyyy yyzzzzzz -> + 11110www 10xxxxxx 10yyyyyy 10zzzzzz) +esid: sec-encodeuricomponent-uricomponent +description: > + Complex tests, use RFC 3629, string.charAt(k) in [0xD800, 0xDBFF, + 0xD9FF] +includes: [decimalToHexString.js] +---*/ + +var chars = [0xD800, 0xDBFF, 0xD9FF]; +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; +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 = 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); + if (encodeURIComponent(str).toUpperCase() === hex4 + hex3 + hex2 + hex1) continue; + + res = false; + } + if (res !== true) { + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + count++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js new file mode 100644 index 0000000000..901ed77d42 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A2.5_T1.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If string.charAt(k) in [0xE000 - 0xFFFF], return 3 octets (xxxxyyyy + yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz) +esid: sec-encodeuricomponent-uricomponent +description: Complex tests, use RFC 3629 +includes: [decimalToHexString.js] +---*/ + +var errorCount = 0; +var count = 0; +var indexP; +var indexO = 0; +for (var index = 0xE000; index <= 0xFFFF; index++) { + count++; + 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); + if (encodeURIComponent(str).toUpperCase() === hex3 + hex2 + hex1) continue; + + if (indexO === 0) { + indexO = index; + } else { + if ((index - indexP) !== 1) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + $ERROR('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + $ERROR('#' + hexP + ' '); + } + $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count + ' '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.1_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.1_T1.js new file mode 100644 index 0000000000..16c2f1cf20 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: unescapedURIComponentSet not containing uriReserved +esid: sec-encodeuricomponent-uricomponent +description: Complex tests +---*/ + +var uriReserved = ["%3B", "%2F", "%3F", "%3A", "%40", "%26", "%3D", "%2B", "%24", "%2C"]; +var uriReserved_ = [";", "/", "?", ":", "@", "&", "=", "+", "$", ","]; +for (var indexC = 0; indexC < 10; indexC++) { + var str = uriReserved_[indexC]; + if (encodeURIComponent(str) !== uriReserved[indexC]) { + $ERROR('#' + (indexC + 1) + ': unescapedURIComponentSet not containing' + str); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T1.js new file mode 100644 index 0000000000..ed31a1e128 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + unescapedURIComponentSet containing one instance of each character valid + in uriUnescaped +esid: sec-encodeuricomponent-uricomponent +description: "Complex tests, uriUnescaped :: uriAlpha" +---*/ + +var uriAlpha = ["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"]; +for (var indexC = 0; indexC < uriAlpha.length; indexC++) { + var str = uriAlpha[indexC]; + if (encodeURIComponent(str) !== str) { + $ERROR('#' + (indexC + 1) + ': unescapedURISet containing ' + str); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T2.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T2.js new file mode 100644 index 0000000000..4b0d44ab1f --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + unescapedURIComponentSet containing one instance of each character valid + in uriUnescaped +esid: sec-encodeuricomponent-uricomponent +description: "Complex tests, uriUnescaped :: DecimalDigit" +---*/ + +var DecimalDigit = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]; +for (var indexC = 0; indexC < DecimalDigit.length; indexC++) { + var str = DecimalDigit[indexC]; + if (encodeURIComponent(str) !== str) { + $ERROR('#' + (indexC + 1) + ': unescapedURISet containing' + str); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T3.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T3.js new file mode 100644 index 0000000000..17611019df --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.2_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + unescapedURIComponentSet containing one instance of each character valid + in uriUnescaped +esid: sec-encodeuricomponent-uricomponent +description: "Complex tests, uriUnescaped :: uriMark" +---*/ + +var uriMark = ["-", "_", ".", "!", "~", "*", "'", "(", ")"]; +for (var indexC = 0; indexC < uriMark.length; indexC++) { + var str = uriMark[indexC]; + if (encodeURIComponent(str) !== str) { + $ERROR('#' + (indexC + 1) + ': unescapedURISet containing' + str); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.3_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.3_T1.js new file mode 100644 index 0000000000..4affb39708 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A3.3_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: unescapedURIComponentSet not containing "#" +esid: sec-encodeuricomponent-uricomponent +description: encodeURIComponent("#") === "%23" +---*/ + +if (encodeURIComponent("#") !== "%23") { + $ERROR('#1: unescapedURIComponentSet not containing "%23"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T1.js new file mode 100644 index 0000000000..b2c412edf3 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: URI tests +esid: sec-encodeuricomponent-uricomponent +description: Checking ENGLISH ALPHABET +---*/ + +//CHECK#1 +if (encodeURIComponent("http://unipro.ru/0123456789") !== "http%3A%2F%2Funipro.ru%2F0123456789") { + $ERROR('#1: http://unipro.ru/0123456789'); +} + +//CHECK#2 +if (encodeURIComponent("aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ") !== "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ") { + $ERROR('#2: aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'); +} + +//CHECK#3 +if (encodeURIComponent(";/?:@&=+$,") !== "%3B%2F%3F%3A%40%26%3D%2B%24%2C") { + $ERROR('#3: '); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T2.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T2.js new file mode 100644 index 0000000000..1245d03d55 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: URI tests +esid: sec-encodeuricomponent-uricomponent +description: Checking RUSSIAN ALPHABET +---*/ + +//CHECK#1 +if ((encodeURIComponent("http://ru.wikipedia.org/wiki/Юникод") !== "http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4") && (encodeURIComponent("http://ru.wikipedia.org/wiki/Юникод") !== "http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F" + "%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4".toLowerCase())) { + $ERROR('#1: http://ru.wikipedia.org/wiki/Юникод'); +} + +//CHECK#2 +if ((encodeURIComponent("http://ru.wikipedia.org/wiki/Юникод#Ссылки") !== "http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%23%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D0%B8") && (encodeURIComponent("http://ru.wikipedia.org/wiki/Юникод#Ссылки") !== "http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F" + "%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%23%D0%A1%D1%81%D1%8B%D0%BB%D0%BA%D0%B8".toLowerCase())) { + $ERROR('#2: http://ru.wikipedia.org/wiki/Юникод#Ссылки'); +} + +//CHECK#3 +if ((encodeURIComponent("http://ru.wikipedia.org/wiki/Юникод#Версии Юникода") !== "http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%23%D0%92%D0%B5%D1%80%D1%81%D0%B8%D0%B8%20%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%D0%B0") && ((encodeURIComponent("http://ru.wikipedia.org/wiki/Юникод%23Версии Юникода") !== "http%3A%2F%2Fru.wikipedia.org%2Fwiki%2F" + "%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4#%D0%92%D0%B5%D1%80%D1%81%D0%B8%D0%B8%20%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4%D0%B0".toLowerCase()))) { + $ERROR('#3: http://ru.wikipedia.org/wiki/Юникод#Версии Юникода'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T3.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T3.js new file mode 100644 index 0000000000..bbb22d395b --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T3.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: URI tests +esid: sec-encodeuricomponent-uricomponent +description: Checking URL with Line Terminator +---*/ + +//CHECK#1 +if ((encodeURIComponent("http://unipro.ru/\nabout") !== "http%3A%2F%2Funipro.ru%2F%0Aabout") && encodeURIComponent("http://unipro.ru/\nabout") !== "http%3A%2F%2Funipro.ru%2F%0aabout") { + $ERROR('#1: http://unipro.ru/\\nabout'); +} + +//CHECK#2 +if ((encodeURIComponent("http://unipro.ru/\vabout") !== "http%3A%2F%2Funipro.ru%2F%0Babout") && encodeURIComponent("http://unipro.ru/\vabout") !== "http%3A%2F%2Funipro.ru%2F%0babout") { + $ERROR('#2: http://unipro.ru/\\vabout'); +} + +//CHECK#3 +if ((encodeURIComponent("http://unipro.ru/\fabout") !== "http%3A%2F%2Funipro.ru%2F%0Cabout") && encodeURIComponent("http://unipro.ru/\fabout") !== "http%3A%2F%2Funipro.ru%2F%0cabout") { + $ERROR('#3: http://unipro.ru/\\fabout'); +} + +//CHECK#4 +if ((encodeURIComponent("http://unipro.ru/\rabout") !== "http%3A%2F%2Funipro.ru%2F%0Dabout") && encodeURIComponent("http://unipro.ru/\rabout") !== "http%3A%2F%2Funipro.ru%2F%0dabout") { + $ERROR('#4: http://unipro.ru/\\rabout'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T4.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T4.js new file mode 100644 index 0000000000..8d9e203fa6 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A4_T4.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: URI tests +esid: sec-encodeuricomponent-uricomponent +description: Test some url +---*/ + +//CHECK#1 +if (encodeURIComponent("") !== "") { + $ERROR('#1: ""'); +} + +//CHECK#2 +if (encodeURIComponent("http://unipro.ru") !== "http%3A%2F%2Funipro.ru") { + $ERROR('#2: http://unipro.ru'); +} + +//CHECK#3 +if (encodeURIComponent("http://www.google.ru/support/jobs/bin/static.py?page=why-ru.html&sid=liveandwork") !== "http%3A%2F%2Fwww.google.ru%2Fsupport%2Fjobs%2Fbin%2Fstatic.py%3Fpage%3Dwhy-ru.html%26sid%3Dliveandwork") { + $ERROR('#3: http://www.google.ru/support/jobs/bin/static.py?page=why-ru.html&sid=liveandwork"'); +} + +//CHECK#4 +if (encodeURIComponent("http://en.wikipedia.org/wiki/UTF-8#Description") !== "http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FUTF-8%23Description") { + $ERROR('#4: http://en.wikipedia.org/wiki/UTF-8#Description'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.1.js new file mode 100644 index 0000000000..fa0d5726d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.1.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of encodeURIComponent has the attribute DontEnum +esid: sec-encodeuricomponent-uricomponent +description: Checking use propertyIsEnumerable, for-in +---*/ + +//CHECK#1 +if (encodeURIComponent.propertyIsEnumerable('length') !== false) { + $ERROR('#1: encodeURIComponent.propertyIsEnumerable(\'length\') === false. Actual: ' + (encodeURIComponent.propertyIsEnumerable('length'))); +} + +//CHECK#2 +var result = true; +for (var p in encodeURIComponent) { + if (p === "length") { + result = false; + } +} + +if (result !== true) { + $ERROR('#2: result = true; for (p in encodeURIComponent) { if (p === "length") result = false; } result === true;'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.2.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.2.js new file mode 100644 index 0000000000..6f8720a3fe --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.2.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The length property of encodeURIComponent does not have the attribute + DontDelete +esid: sec-encodeuricomponent-uricomponent +description: Checking use hasOwnProperty, delete +---*/ + +//CHECK#1 +if (encodeURIComponent.hasOwnProperty('length') !== true) { + $ERROR('#1: encodeURIComponent.hasOwnProperty(\'length\') === true. Actual: ' + (encodeURIComponent.hasOwnProperty('length'))); +} + +delete encodeURIComponent.length; + +//CHECK#2 +if (encodeURIComponent.hasOwnProperty('length') !== false) { + $ERROR('#2: delete encodeURIComponent.length; encodeURIComponent.hasOwnProperty(\'length\') === false. Actual: ' + (encodeURIComponent.hasOwnProperty('length'))); +} + +//CHECK#3 +if (encodeURIComponent.length === undefined) { + $ERROR('#3: delete encodeURIComponent.length; encodeURIComponent.length !== undefined'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.3.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.3.js new file mode 100644 index 0000000000..be5f019d94 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of encodeURIComponent has the attribute ReadOnly +esid: sec-encodeuricomponent-uricomponent +description: Checking if varying the length property fails +includes: [propertyHelper.js] +---*/ + +//CHECK#1 +var x = encodeURIComponent.length; +verifyNotWritable(encodeURIComponent, "length", null, Infinity); +if (encodeURIComponent.length !== x) { + $ERROR('#1: x = encodeURIComponent.length; encodeURIComponent.length = Infinity; encodeURIComponent.length === x. Actual: ' + (encodeURIComponent.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.4.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.4.js new file mode 100644 index 0000000000..2aef581b2e --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.4.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of encodeURIComponent is 1 +esid: sec-encodeuricomponent-uricomponent +description: encodeURIComponent.length === 1 +---*/ + +//CHECK#1 +if (encodeURIComponent.length !== 1) { + $ERROR('#1: encodeURIComponent.length === 1. Actual: ' + (encodeURIComponent.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.5.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.5.js new file mode 100644 index 0000000000..fac57e4fbc --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.5.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The encodeURIComponent property has the attribute DontEnum +esid: sec-encodeuricomponent-uricomponent +description: Checking use propertyIsEnumerable, for-in +---*/ + +//CHECK#1 +if (this.propertyIsEnumerable('encodeURIComponent') !== false) { + $ERROR('#1: this.propertyIsEnumerable(\'encodeURIComponent\') === false. Actual: ' + (this.propertyIsEnumerable('encodeURIComponent'))); +} + +//CHECK#2 +var result = true; +for (var p in this) { + if (p === "encodeURIComponent") { + result = false; + } +} + +if (result !== true) { + $ERROR('#2: result = true; for (p in this) { if (p === "encodeURIComponent") result = false; } result === true;'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.6.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.6.js new file mode 100644 index 0000000000..81649876a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.6.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The encodeURIComponent property has not prototype property +esid: sec-encodeuricomponent-uricomponent +description: Checking encodeURIComponent.prototype +---*/ + +//CHECK#1 +if (encodeURIComponent.prototype !== undefined) { + $ERROR('#1: encodeURIComponent.prototype === undefined. Actual: ' + (encodeURIComponent.prototype)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.7.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.7.js new file mode 100644 index 0000000000..0e3b25359f --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A5.7.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The encodeURIComponent property can't be used as constructor +esid: sec-encodeuricomponent-uricomponent +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new encodeURIComponent(); + $ERROR('#1.1: new encodeURIComponent() throw TypeError. Actual: ' + (new encodeURIComponent())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new encodeURIComponent() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A6_T1.js b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A6_T1.js new file mode 100644 index 0000000000..87ec185fb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A6_T1.js @@ -0,0 +1,129 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator use ToString +esid: sec-encodeuricomponent-uricomponent +description: If Type(value) is Object, evaluate ToPrimitive(value, String) +---*/ + +//CHECK#1 +var object = { + valueOf: function() { + return "^" + } +}; +if (encodeURIComponent(object) !== "%5Bobject%20Object%5D") { + $ERROR('#1: var object = {valueOf: function() {return "^"}}; encodeURIComponent(object) === %5Bobject%20Object%5D. Actual: ' + (encodeURIComponent(object))); +} + +//CHECK#2 +var object = { + valueOf: function() { + return "" + }, + toString: function() { + return "^" + } +}; +if (encodeURIComponent(object) !== "%5E") { + $ERROR('#2: var object = {valueOf: function() {return ""}, toString: function() {return "^"}}; encodeURIComponent(object) === "%5E". Actual: ' + (encodeURIComponent(object))); +} + +//CHECK#3 +var object = { + valueOf: function() { + return "^" + }, + toString: function() { + return {} + } +}; +if (encodeURIComponent(object) !== "%5E") { + $ERROR('#3: var object = {valueOf: function() {return "^"}, toString: function() {return {}}}; encodeURIComponent(object) === "%5E". Actual: ' + (encodeURIComponent(object))); +} + +//CHECK#4 +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return "^" + } + }; + if (encodeURIComponent(object) !== "%5E") { + $ERROR('#4.1: var object = {valueOf: function() {throw "error"}, toString: function() {return "^"}}; encodeURIComponent(object) === "%5E". Actual: ' + (encodeURIComponent(object))); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: var object = {valueOf: function() {throw "error"}, toString: function() {return "^"}}; encodeURIComponent(object) not throw "error"'); + } else { + $ERROR('#4.3: var object = {valueOf: function() {throw "error"}, toString: function() {return "^"}}; encodeURIComponent(object) not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = { + toString: function() { + return "^" + } +}; +if (encodeURIComponent(object) !== "%5E") { + $ERROR('#5: var object = {toString: function() {return "^"}}; encodeURIComponent(object) === "%5E". Actual: ' + (encodeURIComponent(object))); +} + +//CHECK#6 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "^" + } +} +if (encodeURIComponent(object) !== "%5E") { + $ERROR('#6: var object = {valueOf: function() {return {}}, toString: function() {return "^"}}; encodeURIComponent(object) === "%5E". Actual: ' + (encodeURIComponent(object))); +} + +//CHECK#7 +try { + var object = { + valueOf: function() { + return "^" + }, + toString: function() { + throw "error" + } + }; + encodeURIComponent(object); + $ERROR('#7.1: var object = {valueOf: function() {return "^"}, toString: function() {throw "error"}}; encodeURIComponent(object) throw "error". Actual: ' + (encodeURIComponent(object))); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: var object = {valueOf: function() {return "^"}, toString: function() {throw "error"}}; encodeURIComponent(object) throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + encodeURIComponent(object); + $ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; encodeURIComponent(object) throw TypeError. Actual: ' + (encodeURIComponent(object))); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; encodeURIComponent(object) throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/browser.js b/js/src/tests/test262/built-ins/encodeURIComponent/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/browser.js diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/name.js b/js/src/tests/test262/built-ins/encodeURIComponent/name.js new file mode 100644 index 0000000000..6d3594e181 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-encodeuricomponent-uricomponent +description: > + encodeURIComponent.name is "encodeURIComponent". +info: | + encodeURIComponent (uriComponent) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(encodeURIComponent.name, "encodeURIComponent"); + +verifyNotEnumerable(encodeURIComponent, "name"); +verifyNotWritable(encodeURIComponent, "name"); +verifyConfigurable(encodeURIComponent, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js b/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js new file mode 100644 index 0000000000..28030608a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + encodeURIComponent does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(encodeURIComponent), false, 'isConstructor(encodeURIComponent) must return false'); + +assert.throws(TypeError, () => { + new encodeURIComponent(''); +}, '`new encodeURIComponent(\'\')` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/prop-desc.js b/js/src/tests/test262/built-ins/encodeURIComponent/prop-desc.js new file mode 100644 index 0000000000..ff599bc5ce --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-encodeuricomponent-uricomponent +description: Property descriptor for encodeURIComponent +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "encodeURIComponent"); +verifyWritable(this, "encodeURIComponent"); +verifyConfigurable(this, "encodeURIComponent"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/encodeURIComponent/shell.js b/js/src/tests/test262/built-ins/encodeURIComponent/shell.js new file mode 100644 index 0000000000..f1fef84474 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/shell.js @@ -0,0 +1,47 @@ +// GENERATED, DO NOT EDIT +// file: decimalToHexString.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of various encoding operations. +defines: [decimalToHexString, decimalToPercentHexString] +---*/ + +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]; +} + +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} |