diff options
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..93d3f3b9a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T1.js @@ -0,0 +1,55 @@ +// 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++; + 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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..ab8922ae79 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.1_T2.js @@ -0,0 +1,55 @@ +// 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++; + 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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..4352614148 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.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 [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++; + 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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..e66e83a781 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.2_T2.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 [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++; + 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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..cec58ac0d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/S15.1.3.4_A1.3_T1.js @@ -0,0 +1,66 @@ +// 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++) { + 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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..5ea0a727a5 --- /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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..3547470df1 --- /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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..cfc9203ccf --- /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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..0a4736530a --- /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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + count++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..9b8969cd7c --- /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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; + } + count++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..e575947317 --- /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); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } + else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + indexO = index; + } + } + indexP = index; + errorCount++; +} + +if (errorCount > 0) { + if ((indexP - indexO) !== 0) { + var hexP = decimalToHexString(indexP); + var hexO = decimalToHexString(indexO); + throw new Test262Error('#' + hexO + '-' + hexP + ' '); + } else { + var hexP = decimalToHexString(indexP); + throw new Test262Error('#' + hexP + ' '); + } + throw new Test262Error('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..3d684da54b --- /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]) { + throw new Test262Error('#' + (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..26166a3f8a --- /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) { + throw new Test262Error('#' + (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..1ea49b9651 --- /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) { + throw new Test262Error('#' + (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..ebe5b4df49 --- /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) { + throw new Test262Error('#' + (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..5bb0516a4f --- /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") { + throw new Test262Error('#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..2dba5cd5e6 --- /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") { + throw new Test262Error('#1: http://unipro.ru/0123456789'); +} + +//CHECK#2 +if (encodeURIComponent("aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ") !== "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ") { + throw new Test262Error('#2: aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'); +} + +//CHECK#3 +if (encodeURIComponent(";/?:@&=+$,") !== "%3B%2F%3F%3A%40%26%3D%2B%24%2C") { + throw new Test262Error('#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..ccbff45607 --- /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())) { + throw new Test262Error('#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())) { + throw new Test262Error('#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()))) { + throw new Test262Error('#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..f9120f4632 --- /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") { + throw new Test262Error('#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") { + throw new Test262Error('#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") { + throw new Test262Error('#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") { + throw new Test262Error('#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..3b8c4ffc32 --- /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("") !== "") { + throw new Test262Error('#1: ""'); +} + +//CHECK#2 +if (encodeURIComponent("http://unipro.ru") !== "http%3A%2F%2Funipro.ru") { + throw new Test262Error('#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") { + throw new Test262Error('#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") { + throw new Test262Error('#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..8b6d043db0 --- /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) { + throw new Test262Error('#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) { + throw new Test262Error('#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..bacd71e2b0 --- /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) { + throw new Test262Error('#1: encodeURIComponent.hasOwnProperty(\'length\') === true. Actual: ' + (encodeURIComponent.hasOwnProperty('length'))); +} + +delete encodeURIComponent.length; + +//CHECK#2 +if (encodeURIComponent.hasOwnProperty('length') !== false) { + throw new Test262Error('#2: delete encodeURIComponent.length; encodeURIComponent.hasOwnProperty(\'length\') === false. Actual: ' + (encodeURIComponent.hasOwnProperty('length'))); +} + +//CHECK#3 +if (encodeURIComponent.length === undefined) { + throw new Test262Error('#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..9e307bc594 --- /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) { + throw new Test262Error('#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..4602f7d7e0 --- /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) { + throw new Test262Error('#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..ac197e23b1 --- /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) { + throw new Test262Error('#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) { + throw new Test262Error('#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..7ab6c6ffb4 --- /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) { + throw new Test262Error('#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..72ea71fcc4 --- /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(); + throw new Test262Error('#1.1: new encodeURIComponent() throw TypeError. Actual: ' + (new encodeURIComponent())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#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..71a11177a9 --- /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") { + throw new Test262Error('#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") { + throw new Test262Error('#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") { + throw new Test262Error('#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") { + throw new Test262Error('#4.1: var object = {valueOf: function() {throw "error"}, toString: function() {return "^"}}; encodeURIComponent(object) === "%5E". Actual: ' + (encodeURIComponent(object))); + } +} +catch (e) { + if (e === "error") { + throw new Test262Error('#4.2: var object = {valueOf: function() {throw "error"}, toString: function() {return "^"}}; encodeURIComponent(object) not throw "error"'); + } else { + throw new Test262Error('#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") { + throw new Test262Error('#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") { + throw new Test262Error('#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); + throw new Test262Error('#7.1: var object = {valueOf: function() {return "^"}, toString: function() {throw "error"}}; encodeURIComponent(object) throw "error". Actual: ' + (encodeURIComponent(object))); +} +catch (e) { + if (e !== "error") { + throw new Test262Error('#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); + throw new Test262Error('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; encodeURIComponent(object) throw TypeError. Actual: ' + (encodeURIComponent(object))); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#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..a9bb766df3 --- /dev/null +++ b/js/src/tests/test262/built-ins/encodeURIComponent/shell.js @@ -0,0 +1,52 @@ +// 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] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} |