diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/annexB/built-ins/escape | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/annexB/built-ins/escape')
18 files changed, 482 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/escape/argument_bigint.js b/js/src/tests/test262/annexB/built-ins/escape/argument_bigint.js new file mode 100644 index 0000000000..20a0340cce --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/argument_bigint.js @@ -0,0 +1,18 @@ +// Copyright (C) 2020 Qu Xing. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +description: Input is a BigInt +info: | + B.2.1.1 escape ( string ) + + 1. Let string be ? ToString(string). + ... +features: [BigInt] +---*/ + +assert.sameValue(escape(1n), '1'); + +assert.sameValue(escape(-1n), '-1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/argument_types.js b/js/src/tests/test262/annexB/built-ins/escape/argument_types.js new file mode 100644 index 0000000000..cb04677445 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/argument_types.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Qu Xing. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +description: Input is a null, undefined, boolean or Number +info: | + B.2.1.1 escape ( string ) + + 1. Let string be ? ToString(string). + ... +---*/ + +assert.sameValue(escape(null), 'null'); + +assert.sameValue(escape(undefined), 'undefined'); + +assert.sameValue(escape(), 'undefined'); + +assert.sameValue(escape(true), 'true'); + +assert.sameValue(escape(false), 'false'); + +assert.sameValue(escape(-0), '0'); + +assert.sameValue(escape(0), '0'); + +assert.sameValue(escape(1), '1'); + +assert.sameValue(escape(NaN), 'NaN'); + +assert.sameValue(escape(Number.POSITIVE_INFINITY), 'Infinity'); + +assert.sameValue(escape(Number.NEGATIVE_INFINITY), '-Infinity'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/browser.js b/js/src/tests/test262/annexB/built-ins/escape/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/escape/empty-string.js b/js/src/tests/test262/annexB/built-ins/escape/empty-string.js new file mode 100644 index 0000000000..65143c90d1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/empty-string.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Input is the empty string +info: | + 1. Let string be ? ToString(string). + 2. Let length be the number of code units in string. + 3. Let R be the empty string. + 4. Let k be 0. + 5. Repeat, while k < length, + [...] + 6. Return R. +---*/ + +assert.sameValue(escape(''), ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/escape-above-astral.js b/js/src/tests/test262/annexB/built-ins/escape/escape-above-astral.js new file mode 100644 index 0000000000..7ab8e7ed0d --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/escape-above-astral.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Microsoft Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Escaping of code units above 255 from string with extended Unicode escape sequence +info: | + [...] + 5. Repeat, while k < length, + a. Let char be the code unit (represented as a 16-bit unsigned integer) + at index k within string. + [...] + c. Else if char ≥ 256, then + i. Let S be a String containing six code units "%uwxyz" where wxyz + are the code units of the four uppercase hexadecimal digits + encoding the value of char. + [...] +---*/ + +assert.sameValue( + escape('\u{10401}'), '%uD801%uDC01', '\\u{10401} => \\uD801\\uDC01 (surrogate pairs encoded in string)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/escape-above.js b/js/src/tests/test262/annexB/built-ins/escape/escape-above.js new file mode 100644 index 0000000000..347530476e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/escape-above.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Escaping of code units above 255 +info: | + [...] + 5. Repeat, while k < length, + a. Let char be the code unit (represented as a 16-bit unsigned integer) + at index k within string. + [...] + c. Else if char ≥ 256, then + i. Let S be a String containing six code units "%uwxyz" where wxyz + are the code units of the four uppercase hexadecimal digits + encoding the value of char. + [...] +---*/ + +assert.sameValue( + escape('\u0100\u0101\u0102'), '%u0100%u0101%u0102', '\\u0100\\u0101\\u0102' +); + +assert.sameValue( + escape('\ufffd\ufffe\uffff'), '%uFFFD%uFFFE%uFFFF', '\\ufffd\\ufffd\\ufffd' +); + +assert.sameValue( + escape('\ud834\udf06'), '%uD834%uDF06', '\\ud834\\udf06 (surrogate pairs)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/escape-below.js b/js/src/tests/test262/annexB/built-ins/escape/escape-below.js new file mode 100644 index 0000000000..197fcf70e8 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/escape-below.js @@ -0,0 +1,56 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Escaping of code units below 255 +info: | + [...] + 5. Repeat, while k < length, + a. Let char be the code unit (represented as a 16-bit unsigned integer) + at index k within string. + [...] + d. Else char < 256, + i. Let S be a String containing three code units "%xy" where xy are + the code units of two uppercase hexadecimal digits encoding the + value of char. + [...] +---*/ + +assert.sameValue( + escape('\x00\x01\x02\x03'), + '%00%01%02%03', + 'characters: \\x00\\x01\\x02\\x03' +); + +assert.sameValue( + escape('!"#$%&\'()'), + '%21%22%23%24%25%26%27%28%29', + 'characters preceding "*": !"#$%&\'()' +); + +assert.sameValue(escape(','), '%2C', 'character between "+" and "-": ,'); + +assert.sameValue( + escape(':;<=>?'), + '%3A%3B%3C%3D%3E%3F', + 'characters between "9" and "@": :;<=>?' +); + +assert.sameValue( + escape('[\\]^'), '%5B%5C%5D%5E', 'characters between "Z" and "_": [\\]^' +); + +assert.sameValue(escape('`'), '%60', 'character between "_" and "a": `'); + +assert.sameValue( + escape('{|}~\x7f\x80'), + '%7B%7C%7D%7E%7F%80', + 'characters following "z": {|}~\\x7f\\x80' +); + +assert.sameValue( + escape('\xfd\xfe\xff'), '%FD%FE%FF', '\\xfd\\xfe\\xff' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/length.js b/js/src/tests/test262/annexB/built-ins/escape/length.js new file mode 100644 index 0000000000..6d8c672f6e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.1.1 +description: > + escape.length is 1. +info: | + escape (string) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(escape, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/name.js b/js/src/tests/test262/annexB/built-ins/escape/name.js new file mode 100644 index 0000000000..6a3cf986a1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.1.1 +description: > + escape.name is "escape". +info: | + escape (string) + + 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] +---*/ + +verifyProperty(escape, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "escape" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js new file mode 100644 index 0000000000..9fd1e0deb7 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/not-a-constructor.js @@ -0,0 +1,30 @@ +// 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: > + escape 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(escape), false, 'isConstructor(escape) must return false'); + +assert.throws(TypeError, () => { + new escape(''); +}, '`new escape(\'\')` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/prop-desc.js b/js/src/tests/test262/annexB/built-ins/escape/prop-desc.js new file mode 100644 index 0000000000..6669166aae --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: B.2.1 +description: > + Object.getOwnPropertyDescriptor returns data desc for functions on + built-ins (Global.escape) +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof this.escape, "function"); +assert.sameValue(typeof this["escape"], "function"); + +verifyProperty(this, "escape", { + writable: true, + enumerable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/shell.js b/js/src/tests/test262/annexB/built-ins/escape/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// 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; +} diff --git a/js/src/tests/test262/annexB/built-ins/escape/to-primitive-err.js b/js/src/tests/test262/annexB/built-ins/escape/to-primitive-err.js new file mode 100644 index 0000000000..b172fe2b28 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/to-primitive-err.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Qu Xing. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +description: If [Symbol.toPrimitive] method returned an object, it should throw a TypeError +info: | + B.2.1.1 escape ( string ) + + 1. Let string be ? ToString(string). + ... +features: [Symbol.toPrimitive] +---*/ + +var obj = { + toString() { throw new Test262Error('this should be unreachable'); }, + valueOf() { throw new Test262Error('this should be unreachable'); }, + [Symbol.toPrimitive]() { return function(){}; } +}; + +assert.throws(TypeError, function() { + escape(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/to-primitive-observe.js b/js/src/tests/test262/annexB/built-ins/escape/to-primitive-observe.js new file mode 100644 index 0000000000..4b0cc7935c --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/to-primitive-observe.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Qu Xing. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +description: Observable operations from string coercion +info: | + B.2.1.1 escape ( string ) + + 1. Let string be ? ToString(string). + ... +features: [Symbol.toPrimitive] +---*/ + +var obj = { + toString() { throw new Test262Error('this should be unreachable'); }, + valueOf() { throw new Test262Error('this should be unreachable'); }, + [Symbol.toPrimitive]() { return 'success'; } +}; + +assert.sameValue(escape(obj), 'success'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/to-string-err-symbol.js b/js/src/tests/test262/annexB/built-ins/escape/to-string-err-symbol.js new file mode 100644 index 0000000000..6cd2663e3f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/to-string-err-symbol.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Abrupt completion from `ToString` operation (Symbol value) +info: | + 1. Let string be ? ToString(string). +features: [Symbol] +---*/ + +var s = Symbol(''); + +assert.throws(TypeError, function() { + escape(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/to-string-err.js b/js/src/tests/test262/annexB/built-ins/escape/to-string-err.js new file mode 100644 index 0000000000..5d5aaa8b2f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/to-string-err.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Abrupt completion from `ToString` operation +info: | + 1. Let string be ? ToString(string). +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + escape(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/to-string-observe.js b/js/src/tests/test262/annexB/built-ins/escape/to-string-observe.js new file mode 100644 index 0000000000..c9dcd49f99 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/to-string-observe.js @@ -0,0 +1,54 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Observable operations from string coercion +info: | + 1. Let string be ? ToString(string). +---*/ + +var log, obj; + +log = ''; +obj = { + toString: function() { + log += 'toString'; + }, + valueOf: function() { + log += 'valueOf'; + } +}; + +escape(obj); + +assert.sameValue(log, 'toString'); + +log = ''; +obj = { + toString: null, + valueOf: function() { + log += 'valueOf'; + } +}; + +escape(obj); + +assert.sameValue(log, 'valueOf'); + +log = ''; +obj = { + toString: function() { + log += 'toString'; + return {}; + }, + valueOf: function() { + log += 'valueOf'; + } +}; + +escape(obj); + +assert.sameValue(log, 'toStringvalueOf'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/escape/unmodified.js b/js/src/tests/test262/annexB/built-ins/escape/unmodified.js new file mode 100644 index 0000000000..0f8e82c4ae --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/escape/unmodified.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-escape-string +es6id: B.2.1.1 +description: Do not escape a specific set of characters +info: | + [...] + 5. Repeat, while k < length, + a. Let char be the code unit (represented as a 16-bit unsigned integer) + at index k within string. + b. If char is one of the code units in + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./", + then + i. Let S be a String containing the single code unit char. + [...] +---*/ + +var passthrough = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./'; + +assert.sameValue(escape(passthrough), passthrough); + +reportCompare(0, 0); |